Class UrlUtils

java.lang.Object
org.eblocker.server.common.util.UrlUtils

public class UrlUtils extends Object
  • Constructor Details

    • UrlUtils

      public UrlUtils()
  • Method Details

    • getHostname

      public static String getHostname(String urlString)
    • isUkStyleTdl

      public static boolean isUkStyleTdl(String hostname)
    • getDomain

      public static String getDomain(String hostname)
    • isUrl

      public static boolean isUrl(String url)
    • isUrlWithoutProtocol

      public static boolean isUrlWithoutProtocol(String url)
    • findUrlParameter

      public static String findUrlParameter(String requestUrl, String urlParam)
    • isSameDomain

      public static boolean isSameDomain(String domain, String hostname)
    • isInvalidDomain

      public static boolean isInvalidDomain(String url)
      Checks whether the domain part of this url is a just a Top Level Domain (or invalid wildcard like '.'), which would be a big wildcard including lots of domains, and should therefore be forbidden to add. Domains may be given as bare domains (e.g. www.server.tld) but also as URLs as copy-pasted from the browsers address bar (e.g. https://user:pass@server.tld/folder/script.php?param=value&param2=value2)
      Parameters:
      url - The URL to check
      Returns:
      true if the URL contains a valid domain
    • findDomainInString

      public static String findDomainInString(String url, boolean allowIpAddress)
    • urlEncode

      public static String urlEncode(String value)
    • urlDecode

      public static String urlDecode(String value)
    • getOrigin

      public static String getOrigin(String url)
      Returns only the origin of a given URL
      Parameters:
      url - full URL
      Returns:
      origin of the URL, given by scheme, hostname and port (if specified)