public class

URLUtil

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

Summary

Public Constructors
URLUtil()
Public Methods
static String addXsrfToken(String token, String url)
Adds a token to a given url in the FIRST position
static boolean compareURLStrings(String controlLink, String testLink)
Compares 2 URL strings for equality.
static String decode(String urlParam)
The opposite of encode(String)
static String encode(String urlParam)
Can be called to encode a parameter part of an URL
static String getQueryParamValueFromUrl(String url, String paramName)
static String getQueryParamValueFromUrl(URL url, String paramName)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public URLUtil ()

Public Methods

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

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.

public static String decode (String urlParam)

The opposite of encode(String)

Parameters
urlParam the param to decode
Returns
  • the decoded value

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

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.

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.