Skip to content

Commit

Permalink
better url handling, suppressing empty custom links
Browse files Browse the repository at this point in the history
  • Loading branch information
bischoffdev committed Sep 29, 2022
1 parent c6f4855 commit 5307fd0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Back to [Readme](README.md).

## [2.9.3] - 2022-09-29

### Added
* Custom parameter values starting with `./`, `../` or `#` are now interpreted as relative URLs
* Custom navigation links without values are now hidden

## [2.9.2] - 2022-09-27

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion example-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>blog.softwaretester</groupId>
<artifactId>cluecumber-test-project</artifactId>
<version>2.9.2</version>
<version>2.9.3</version>
<packaging>pom</packaging>

<properties>
Expand Down Expand Up @@ -42,6 +42,7 @@
<customParameters>
<Custom_Parameter>This is a test</Custom_Parameter>
<Custom_URL>https://www.google.com</Custom_URL>
<Custom_Relative_URL>./css/cluecumber.css</Custom_Relative_URL>
<_KeysStartingWithAnUnderscoreAreHidden>This is a long text that is displayed without the key.
This can be used to display longer texts in the report!
</_KeysStartingWithAnUnderscoreAreHidden>
Expand Down Expand Up @@ -85,9 +86,11 @@
<!-- Optionally skip the whole report generation -->
<!--<skip>true</skip>-->

<!-- Optional custom navigation links that are shown in the main top navigation (if they have a value) -->
<customNavigationLinks>
<Test_Blog>https://www.softwaretester.blog</Test_Blog>
<Twitter>https://twitter.com/BischoffDev</Twitter>
<Empty_Link></Empty_Link>
</customNavigationLinks>
</configuration>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion plugin-code/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.trivago.rta</groupId>
<artifactId>cluecumber-report-plugin</artifactId>
<version>2.9.2</version>
<version>2.9.3</version>
<url>https://github.com/trivago/cluecumber-report-plugin</url>

<name>Cluecumber Maven Plugin for Cucumber Reports</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public boolean isUrl() {
return RenderingUtils.isUrl(getValue());
}

public boolean isRelativeUrl() {
return RenderingUtils.isRelativeUrl(getValue());
}

@Override
public String toString() {
return "CustomParameter{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,8 @@ public static boolean isUrl(String value) {
return false;
}
}

public static boolean isRelativeUrl(final String value){
return value.startsWith("./") || value.startsWith("../") || value.startsWith("#");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ limitations under the License.
<#if !customParameter.key?starts_with(" ")>
<td class="text-left text-nowrap"><strong>${customParameter.key}:</strong></td>
<td class="text-left wrap">
<#if customParameter.url>
<#if customParameter.url || customParameter.relativeUrl>
<a href="${customParameter.value}" style="word-break: break-all;"
target="_blank">${customParameter.value}</a>
<#else>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ limitations under the License.
</#switch>
<a class="nav-link ${highlightClass}" href="${link.target}">${name}</a>
<#elseif link.type == "EXTERNAL">
<div class=""><a class="nav-link customLink" href="${link.target}" target="_blank">${link.name}</a></div>
<#if link.target??>
<a class="nav-link customLink" href="${link.target}" target="_blank">${link.name}</a>
</#if>
</#if>
</li>
</#list>
Expand Down

0 comments on commit 5307fd0

Please sign in to comment.