Java URL Normalize normalizeShortUrl(String url)

Here you can find the source of normalizeShortUrl(String url)

Description

normalize Short Url

License

Apache License

Declaration

public static String normalizeShortUrl(String url) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String normalizeShortUrl(String url) {
        //TODO now only check matching short url, so don't care about RFC standard
        url = url.toLowerCase();/*from   www.  j ava 2  s . c o  m*/
        url = url.replaceAll("^(^(http|https)://)|www.", "");
        url = url.replaceAll("//", "");
        int endIndex = url.lastIndexOf("/");
        if (endIndex == (url.length() - 1)) {
            url = url.substring(0, endIndex);
        }
        return url;
    }
}

Related

  1. normalize(URL url)
  2. normalize(URL url)
  3. normalizeBaseUrl(String networkUrl)
  4. normalizeCapabilitiesUrl(String url)
  5. normalizePrefix(String url)
  6. normalizeToLUrl(String toLUrl)
  7. normalizeToURL(String surl)
  8. NormalizeURL(final String taintedURL)
  9. normalizeUrl(final String url)