Skip to content

Commit 1127253

Browse files
committed
Centralize slash character in static final variable, improves clarity and maintainability.
1 parent 04c8344 commit 1127253

File tree

1 file changed

+4
-3
lines changed
  • spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web

1 file changed

+4
-3
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/EndpointMapping.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
public class EndpointMapping {
2828

2929
private final String path;
30+
private static final String SLASH = "/";
3031

3132
/**
3233
* Creates a new {@code EndpointMapping} using the given {@code path}.
@@ -53,10 +54,10 @@ private static String normalizePath(String path) {
5354
return path;
5455
}
5556
String normalizedPath = path;
56-
if (!normalizedPath.startsWith("/")) {
57-
normalizedPath = "/" + normalizedPath;
57+
if (!normalizedPath.startsWith(SLASH)) {
58+
normalizedPath = SLASH + normalizedPath;
5859
}
59-
if (normalizedPath.endsWith("/")) {
60+
if (normalizedPath.endsWith(SLASH)) {
6061
normalizedPath = normalizedPath.substring(0, normalizedPath.length() - 1);
6162
}
6263
return normalizedPath;

0 commit comments

Comments
 (0)