List of utility methods to do URL Normalize
URL | normalizeUrl(URL url) Normalizes the given URL path to remove relative folder path references (e.g. String urlPath = url.getPath(); URL result = url; if ((urlPath.indexOf("/./") >= 0) || (urlPath.indexOf("/../") >= 0)) { try { String sourceUrl = url.toExternalForm(); StringBuilder targetUrl = new StringBuilder(sourceUrl.substring(0, sourceUrl.lastIndexOf(urlPath))); List<String> pathList = new ArrayList<String>(); boolean pathStarted = false; ... |
URL | normalizeURL(URL url) normalize URL if (url == null) return null; String urlString = url.toString(); if (urlString.endsWith("/")) { urlString = urlString.substring(0, urlString.length() - 1); try { return new URL(urlString); ... |
String | normalizeUrl(URL url) Returns a string containing a properly formed URL with port and scheme information. int port = url.getPort(); String portString = ""; String protocol = url.getProtocol().toLowerCase(); String file = url.getFile(); String query = url.getQuery(); if (port == -1) port = (url.getProtocol().equals("https")) ? 443 : 80; if ((protocol.equals("http") && port != 80) || (protocol.equals("https") && port != 443)) ... |
URL | normalizeUrl(URL url) normalize Url if (url == null) return (null); String urlStr = url.toString(); if (urlStr.endsWith("/")) { return (new URL(urlStr.substring(0, urlStr.length() - 1))); return (url); |
URL | normalizeURL(URL url) Normalize a URL, by forcing its host name and protocol to lower case. try { String protocol = url.getProtocol().toLowerCase(); String host = url.getHost().toLowerCase(); int port = url.getPort(); String file = url.getFile(); String ref = url.getRef(); if ((ref != null) && (ref.length() > 0)) file = file + "#" + ref; ... |
String | normalizeUrlStr(String urlStr) normalize Url Str if (urlStr == null) return (null); if (!urlStr.startsWith("http://")) urlStr = "http://" + urlStr; if (urlStr.endsWith("/")) return (urlStr.substring(0, urlStr.length() - 1)); return (urlStr); |