Class UrlUtils


  • public class UrlUtils
    extends Object
    • Constructor Detail

      • UrlUtils

        private UrlUtils()
    • Method Detail

      • extractNewUrl

        public static URI extractNewUrl​(String currentUrl,
                                        String href)
        Parameters:
        currentUrl - The current url
        href - The target URL, relative or not
        Returns:
        The new URL.
      • isJavascript

        private static boolean isJavascript​(String href)
      • getBaseUrl

        public static String getBaseUrl​(String url)
        Parameters:
        url - the URL string. It must contain with ":" e.g, http: or https:
        Returns:
        the base part of the URL.
      • getVarFromQueryString

        public static String getVarFromQueryString​(String varName,
                                                   String haystack)
        Retrieve the var value for varName from a HTTP query string (format is "var1=val1&var2=val2").
        Parameters:
        varName - the name.
        haystack - the haystack.
        Returns:
        variable value for varName
      • isSameDomain

        public static boolean isSameDomain​(String currentUrl,
                                           URI url)
        Checks if the given URL is part of the domain, or a sub-domain of the given URI.
        Parameters:
        currentUrl - The url you want to check.
        url - The URL acting as the base.
        Returns:
        If the URL is part of the domain.