Skip to content

Commit

Permalink
Polish "Avoid unnecessary pattern compilation in WebFluxTags"
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Nov 18, 2020
1 parent b22bb7e commit d344088
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,20 @@ public static Tag uri(ServerWebExchange exchange, boolean ignoreTrailingSlash) {
return URI_UNKNOWN;
}

private static String removeTrailingSlash(String text) {
if (!StringUtils.hasLength(text)) {
return text;
}
return text.endsWith("/") ? text.substring(0, text.length() - 1) : text;
}

private static String getPathInfo(ServerWebExchange exchange) {
String path = exchange.getRequest().getPath().value();
String uri = StringUtils.hasText(path) ? path : "/";
String singleSlashes = FORWARD_SLASHES_PATTERN.matcher(uri).replaceAll("/");
return removeTrailingSlash(singleSlashes);
}

private static String removeTrailingSlash(String text) {
if (!StringUtils.hasLength(text)) {
return text;
}
return text.endsWith("/") ? text.substring(0, text.length() - 1) : text;
}

/**
* Creates an {@code exception} tag based on the {@link Class#getSimpleName() simple
* name} of the class of the given {@code exception}.
Expand Down

0 comments on commit d344088

Please sign in to comment.