java.lang.Object
com.atlassian.jira.functest.framework.util.url.URLUtil

public class URLUtil extends Object
Since:
v3.13
  • Constructor Details

    • URLUtil

      public URLUtil()
  • Method Details

    • compareURLStrings

      public static boolean compareURLStrings(String controlLink, String testLink)
      Compares 2 URL strings for equality. Two URLs will be equal, if their baseURL is the same, and they have the same parameters (regardless of ordering). The baseURL does not include contextPath.

      For example: ViewWorkflowSteps.jspa?workflowMode=live&workflowName=Dude AND /jira/ViewWorkflowSteps.jspa?workflowName=Dude&workflowMode=live are deemed to be equal by this method.

      Amazingly enough I couldn't find an open source helper that already does this!

      Parameters:
      controlLink - The link assumed to be correct.
      testLink - The link being tested.
      Returns:
      True if the two links are correct.
    • getQueryParamValueFromUrl

      public static String getQueryParamValueFromUrl(String url, String paramName)
      Parameters:
      url - the url to process e.g. http://www.atlassian.com/search?blablabla=haha&test=two
      paramName - the name of the parameter to retrieve the value of
      Returns:
      the value of the query parameter from the URL string; null if there was no query part or the fieldId could not be found.
    • getQueryParamValueFromUrl

      public static String getQueryParamValueFromUrl(URL url, String paramName)
      Parameters:
      url - the url to process
      paramName - the name of the parameter to retrieve the value of
      Returns:
      the value of the query parameter from the URL string; null if there was no query part or the fieldId could not be found.
    • addXsrfToken

      public static String addXsrfToken(String token, String url)
      Adds a token to a given url in the FIRST position
      Parameters:
      token - the token
      url - the url in question
      Returns:
      the url with the token in place
    • encode

      public static String encode(String urlParam)
      Can be called to encode a parameter part of an URL
      Parameters:
      urlParam - the parameter to be plaved into a URL
      Returns:
      the encoded data
    • decode

      public static String decode(String urlParam)
      The opposite of encode(String)
      Parameters:
      urlParam - the param to decode
      Returns:
      the decoded value