public class UrlUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
appendSlashIfDoesntExist(String theString)
Checks whether or not the given string has a '/' character as the last character, and appends one if it doesn't
|
static String |
constructBaseUrl(javax.servlet.http.HttpServletRequest request)
Attempts to construct a baseUrl using the
HttpServletRequest object. |
static String |
correctlyFormatUrl(String host) |
static URL |
createUrl(String url) |
static URL |
createUrl(String context,
String formActionDestination) |
static com.google.common.collect.Multimap<String,String> |
extractQueryParams(String url) |
static com.google.common.collect.Multimap<String,String> |
extractQueryParams(URI uri) |
static com.google.common.collect.Multimap<String,String> |
extractQueryParams(URL url) |
static String |
extractSingleQueryParam(String url,
String paramName) |
static String |
extractSingleQueryParam(URL url,
String paramName) |
static String |
getPathUnderContext(String url,
String context)
Deprecated.
|
static boolean |
hasXssRelatedCharacters(String string) |
static boolean |
isSameOrigin(URL url,
URL origin) |
static String |
prependSlashIfDoesntExist(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 String |
replaceOrInsertParamValue(String queryString,
String newParamValue) |
static String |
replacePlanResultKeyInUrl(String url,
PlanKey planKey,
int newBuildNumber) |
static String |
sanitizeUri(String uri)
Removes XSS related characters from URI: backslash, double and single quotes, angle brackets.
|
static String |
stripLeadingSlashes(String toStrip)
Strips any leading '/' characters off the front of the string, if any.
|
static String |
stripTailingSlashes(String toStrip)
Strips any leading '/' characters off the end of the string, if any.
|
@NotNull public static String sanitizeUri(@NotNull String uri)
uri
- @Nullable public static String replaceOrInsertParamValue(String queryString, String newParamValue)
public static String replacePlanResultKeyInUrl(String url, PlanKey planKey, int newBuildNumber)
@NotNull public static String stripLeadingSlashes(@Nullable String toStrip)
toStrip
- - the string to strip@NotNull public static String stripTailingSlashes(@Nullable String toStrip)
toStrip
- - the string to strip@NotNull public static String appendSlashIfDoesntExist(@Nullable String theString)
theString
- to check and append.@NotNull public static String prependSlashIfDoesntExist(@Nullable String theString)
theString
- to check and prepend.@Deprecated public static String getPathUnderContext(@NotNull String url, @NotNull String context)
UrlUtils.getPathUnderContext(java.lang.String, java.lang.String)
for context description
@NotNull public static com.google.common.collect.Multimap<String,String> extractQueryParams(@NotNull URL url)
@NotNull public static com.google.common.collect.Multimap<String,String> extractQueryParams(@NotNull String url)
@NotNull public static com.google.common.collect.Multimap<String,String> extractQueryParams(@NotNull URI uri)
@Nullable public static String extractSingleQueryParam(@NotNull URL url, @NotNull String paramName)
@Nullable public static String extractSingleQueryParam(@NotNull String url, @NotNull String paramName)
public static boolean isSameOrigin(@NotNull URL url, @NotNull URL origin)
url
- the url to checkorigin
- the origin to check against.@NotNull public static URL createUrl(@NotNull String context, @NotNull String formActionDestination)
public static String constructBaseUrl(javax.servlet.http.HttpServletRequest request)
HttpServletRequest
object.request
- The incoming http requestpublic static boolean hasXssRelatedCharacters(@Nullable String string)
Copyright © 2020 Atlassian Software Systems Pty Ltd. All rights reserved.