Skip to content

Commit 4e2f0db

Browse files
committed
The hardcoded '.' and '\\' parts have been modified to
EXTENSION_SEPARATOR WINDOWS_FOLDER_SEPARATOR_CHAR. The '\\' part can be added to WINDOWS_FOLDER_SEPARATOR_CHAR to maintain overall consistency in the codebase.
1 parent d89983d commit 4e2f0db

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spring-core/src/main/java/org/springframework/util/StringUtils.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
* @author Sam Brannen
6161
* @author Brian Clozel
6262
* @author Sebastien Deleuze
63+
* @author SungJun Park
6364
* @since 16 April 2001
6465
*/
6566
public abstract class StringUtils {
@@ -72,6 +73,8 @@ public abstract class StringUtils {
7273

7374
private static final String WINDOWS_FOLDER_SEPARATOR = "\\";
7475

76+
private static final char WINDOWS_FOLDER_SEPARATOR_CHAR = '\\';
77+
7578
private static final String DOUBLE_BACKSLASHES = "\\\\";
7679

7780
private static final String TOP_PATH = "..";
@@ -712,7 +715,7 @@ public static String cleanPath(String path) {
712715

713716
String normalizedPath;
714717
// Optimize when there is no backslash
715-
if (path.indexOf('\\') != -1) {
718+
if (path.indexOf(WINDOWS_FOLDER_SEPARATOR_CHAR) != -1) {
716719
normalizedPath = replace(path, DOUBLE_BACKSLASHES, FOLDER_SEPARATOR);
717720
normalizedPath = replace(normalizedPath, WINDOWS_FOLDER_SEPARATOR, FOLDER_SEPARATOR);
718721
}
@@ -722,7 +725,7 @@ public static String cleanPath(String path) {
722725
String pathToUse = normalizedPath;
723726

724727
// Shortcut if there is no work to do
725-
if (pathToUse.indexOf('.') == -1) {
728+
if (pathToUse.indexOf(EXTENSION_SEPARATOR) == -1) {
726729
return pathToUse;
727730
}
728731

0 commit comments

Comments
 (0)