code: public static String stripDefaultPortFromUrl(String url) {
  		String scheme = urlToScheme(url);
  		if(scheme == null) {
  			return url;
  		}
  		int defaultPort = schemeToDefaultPort(scheme);
  		if(defaultPort == -1) {
  			return url;
  		}
  
  		String portStr = null;
  		// is there a slash after the scheme?
  		int slashIdx = url.indexOf('/', scheme.length());
  		if(slashIdx == -1) {
  			portStr = String.format(":%d", defaultPort);
  			if(url.endsWith(portStr)) {
  				return url.substring(0,url.length() - portStr.length());
  			}
  		}
  		portStr = String.format(":%d/", defaultPort);
  		int idx = url.indexOf(portStr);
  		if(idx == -1) {
  			return url;
  		}
  		// if that occurred before the first / (after the scheme) then strip it:
  		if(slashIdx < idx) {
  			return url;
  		}
  		// we want to strip out the portStr:
  		StringBuilder sb = new StringBuilder(url.length());
  		sb.append(url.substring(0,idx));
  		sb.append(url.substring(idx + (portStr.length()-1)));
  		return sb.toString();
  	}
docs: Attempt to strip default ports out of URL strings.
  @param url the original URL possibly including a port
  @return the URL sans port, if the scheme was recognized and the default
  port was supplied, otherwise, the original URL.