com.atlassian.bamboo.util
Class UrlUtils

java.lang.Object
  extended by com.atlassian.bamboo.util.UrlUtils

public class UrlUtils
extends java.lang.Object


Method Summary
static java.lang.String appendSlashIfDoesntExist(java.lang.String theString)
          Checks whether or not the given string has a '/' character as the last character, and appends one if it doesn't
static java.lang.String correctlyFormatUrl(java.lang.String host)
           
static java.lang.String getPathUnderContext(java.lang.String url, java.lang.String context)
          Given an URL which may: - include scheme,host and optionally port - start directly with context - start with an arbitrary path under a context this method returns the path under context.
static java.lang.String prependSlashIfDoesntExist(java.lang.String theString)
          Checks whether or not the given string has a '/' character as the first character, and puts one in if it doesn't
static java.lang.String replaceOrInsertParamValue(java.lang.String queryString, java.lang.String newParamValue)
           
static java.lang.String replacePlanResultKeyInUrl(java.lang.String url, PlanKey planKey, int newBuildNumber)
           
static java.lang.String sanitizeUri(java.lang.String uri)
          Removes XSS related characters from URI: backslash, double and single quotes, angle brackets.
static java.lang.String stripLeadingSlashes(java.lang.String toStrip)
          Strips any leading '/' characters off the front of the string, if any.
static java.lang.String stripTailingSlashes(java.lang.String toStrip)
          Strips any leading '/' characters off the end of the string, if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sanitizeUri

@NotNull
public static java.lang.String sanitizeUri(@NotNull
                                                   java.lang.String uri)
Removes XSS related characters from URI: backslash, double and single quotes, angle brackets.

Parameters:
uri -
Returns:

replaceOrInsertParamValue

@Nullable
public static java.lang.String replaceOrInsertParamValue(java.lang.String queryString,
                                                                  java.lang.String newParamValue)

replacePlanResultKeyInUrl

public static java.lang.String replacePlanResultKeyInUrl(java.lang.String url,
                                                         PlanKey planKey,
                                                         int newBuildNumber)

correctlyFormatUrl

public static java.lang.String correctlyFormatUrl(java.lang.String host)

stripLeadingSlashes

@NotNull
public static java.lang.String stripLeadingSlashes(@Nullable
                                                           java.lang.String toStrip)
Strips any leading '/' characters off the front of the string, if any.

Parameters:
toStrip - - the string to strip
Returns:
the string without the leading '/' characters

stripTailingSlashes

@NotNull
public static java.lang.String stripTailingSlashes(@Nullable
                                                           java.lang.String toStrip)
Strips any leading '/' characters off the end of the string, if any.

Parameters:
toStrip - - the string to strip
Returns:
the string without the end '/' characters

appendSlashIfDoesntExist

@NotNull
public static java.lang.String appendSlashIfDoesntExist(@Nullable
                                                                java.lang.String theString)
Checks whether or not the given string has a '/' character as the last character, and appends one if it doesn't

Parameters:
theString - to check and append.
Returns:
the original string with the extra '/' if required.

prependSlashIfDoesntExist

@NotNull
public static java.lang.String prependSlashIfDoesntExist(@Nullable
                                                                 java.lang.String theString)
Checks whether or not the given string has a '/' character as the first character, and puts one in if it doesn't

Parameters:
theString - to check and prepend.
Returns:
the original string with the extra '/' if required.

getPathUnderContext

public static java.lang.String getPathUnderContext(@NotNull
                                                   java.lang.String url,
                                                   @NotNull
                                                   java.lang.String context)
Given an URL which may: - include scheme,host and optionally port - start directly with context - start with an arbitrary path under a context this method returns the path under context. It should not be used for security purposes, because it operates on best effort basis - including returning the URL without modifications if context is not found .

See Also:
for context description


Copyright © 2012 Atlassian. All Rights Reserved.