com.atlassian.jira.functest.framework.util.url
Class URLUtil

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

public class URLUtil
extends Object

Since:
v3.13

Constructor Summary
URLUtil()
           
 
Method Summary
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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLUtil

public URLUtil()
Method Detail

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


Copyright © 2002-2014 Atlassian. All Rights Reserved.