private static String normalizeURL ( String urlString ) throws MalformedURLException { URL url = new URL ( urlString ) ; if ( url . getPort ( ) == - 1 ) { return url . getProtocol ( ) + "://" + url . getHost ( ) + ":" + url . getDefaultPort ( ) + url . getFile ( ) + ( url . getRef ( ) != null ? "#" + url . getRef ( ) : "" ) ; } else { return urlString ; } }
Return a URL string in which the port is always specified .