Here you can find the source of normalizeUrl(String url)
public static String normalizeUrl(String url)
//package com.java2s; /**/*from w w w .j a v a 2s . c om*/ * Copyright 2010-2011 Buhake Sindi Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ public class Main { public static String normalizeUrl(String url) { int questionMarkIndex = url.indexOf('?'); if (questionMarkIndex > -1) { url = url.substring(0, questionMarkIndex); } int forwardSlashIndex = url.indexOf('/', 8); if (forwardSlashIndex > -1) { int colonIndex = url.lastIndexOf(':', forwardSlashIndex); if (colonIndex > -1) { String port = url.substring(colonIndex, forwardSlashIndex); if ((url.startsWith("http://") && (port.equals(":80") || port .equals(":8080"))) || (url.startsWith("https://") && port .equals(":443"))) { url = url.substring(0, colonIndex) + url.substring(colonIndex + port.length()); } } } return url.toLowerCase(); } }