Here you can find the source of normalizeUrl(String url)
private static String normalizeUrl(String url) throws URISyntaxException
//package com.java2s; //License from project: Apache License import java.net.URI; import java.net.URISyntaxException; public class Main { private static String normalizeUrl(String url) throws URISyntaxException { URI uri = new URI(url); String scheme = uri.getScheme().toLowerCase(); String authority = uri.getAuthority().toLowerCase(); boolean dropPort = ((scheme.equals("http")) && (uri.getPort() == 80)) || ((scheme.equals("https")) && (uri.getPort() == 443)); if (dropPort) { int index = authority.lastIndexOf(":"); if (index >= 0) { authority = authority.substring(0, index); }/* w w w . j a va 2s.c o m*/ } String path = uri.getRawPath(); if ((path == null) || (path.length() <= 0)) { path = "/"; } return scheme + "://" + authority + path; } }