private String normalizePath(String path) { if ("".equals(path)) { return isScheme("http") || isScheme("https") ? "/" : ""; } else if (isScheme("file")) { if (path.indexOf("%5C") >= 0) { // replace "/c:\path\to\file" with "/c:/path/to/file" return normalizePath(path.replace("%5C", "/")); } else if (!path.startsWith("/") && isMember(ALPHA, path.codePointAt(0)) && (':' == path.charAt(1) || path.length() >= 4 && "%7C".equals(path.substring(1, 4)))) { // replace "c:/path/to/file" with "/c:/path/to/file" return normalizePath("/" + path); } else if (path.length() >= 5 && "%7C".equals(path.substring(2, 5)) && isMember(ALPHA, path.codePointAt(1))) { // replace "/c|/path/to/file" with "/c:/path/to/file" return normalizePath(path.substring(0, 2) + ':' + path.substring(5)); } } return pctEncodingNormalization(pathSegmentNormalization(path)); }
private String normalizePath(String path) { if ("".equals(path)) { return isScheme("http") || isScheme("https") ? "/" : ""; } else if (isScheme("file")) { if (path.indexOf("%5C") >= 0) { // replace "/c:\path\to\file" with "/c:/path/to/file" return normalizePath(path.replace("%5C", "/")); } else if (!path.startsWith("/") && isMember(ALPHA, path.codePointAt(0)) && (':' == path.charAt(1) || path.length() >= 4 && "%7C".equals(path.substring(1, 4)))) { // replace "c:/path/to/file" with "/c:/path/to/file" return normalizePath("/" + path); } else if (path.length() >= 5 && "%7C".equals(path.substring(2, 5)) && isMember(ALPHA, path.codePointAt(1))) { // replace "/c|/path/to/file" with "/c:/path/to/file" return normalizePath(path.substring(0, 2) + ':' + path.substring(5)); } } return pctEncodingNormalization(pathSegmentNormalization(path)); }
private String normalizePath(String path) { if ("".equals(path)) { return isScheme("http") || isScheme("https") ? "/" : ""; } else if (isScheme("file")) { if (path.indexOf("%5C") >= 0) { // replace "/c:\path\to\file" with "/c:/path/to/file" return normalizePath(path.replace("%5C", "/")); } else if (!path.startsWith("/") && isMember(ALPHA, path.codePointAt(0)) && (':' == path.charAt(1) || path.length() >= 4 && "%7C".equals(path.substring(1, 4)))) { // replace "c:/path/to/file" with "/c:/path/to/file" return normalizePath("/" + path); } else if (path.length() >= 5 && "%7C".equals(path.substring(2, 5)) && isMember(ALPHA, path.codePointAt(1))) { // replace "/c|/path/to/file" with "/c:/path/to/file" return normalizePath(path.substring(0, 2) + ':' + path.substring(5)); } } return pctEncodingNormalization(pathSegmentNormalization(path)); }