Package com.atlassian.confluence.util
Class UrlUtils
java.lang.Object
com.atlassian.confluence.util.UrlUtils
Contains url utility methods.
- Since:
- 5.2
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
addContextPath
(String url, ContextPathHolder contextPathHolder) Adds the context path to the given url, if required.static String
Appends an ampersand if the given string already contains a question mark, or a question mark otherwise.static String
getJdbcUrlQuery
(String jdbcUrl) Parses the query string from a JDBC URL.static boolean
isAbsoluteUrl
(String url) Checks if the given URL is absolute.static boolean
static boolean
isBlogPostEditUrl
(String url) static boolean
isEditingUrl
(String url) static boolean
isEditorLoaderUrl
(String url) static boolean
isPageCreationUrl
(String url) static boolean
isPageEditUrl
(String url) static boolean
isResumeDraftUrl
(String url) static boolean
isSafeTitleForUrl
(String title) static boolean
isSameOrigin
(URL url, URL origin) static boolean
static boolean
isTemplateEditUrl
(String url) static String
removeUrlsFromString
(String text) Remove all Urls from a stringstatic boolean
Checks if the supplied URL is valid.
-
Field Details
-
URL_PATTERN
-
-
Constructor Details
-
UrlUtils
public UrlUtils()
-
-
Method Details
-
isSameOrigin
- Parameters:
url
- the url to checkorigin
- the origin to check against.- Returns:
- true if the given url is the same origin as the given origin url otherwise returns false.
-
addContextPath
Adds the context path to the given url, if required.- Parameters:
url
- the url to add the context path to.contextPathHolder
- the holder for the context path to add.- Returns:
- the url including the context path, if the url is relative. Otherwise, the original url.
-
verifyUrl
Checks if the supplied URL is valid.- Parameters:
url
- the URL to check- Returns:
- boolean indicating whether or not it is valid
-
isAbsoluteUrl
Checks if the given URL is absolute.- Parameters:
url
- the URL to check.- Returns:
- true, if the URL starts with either the http or https protocol.
-
removeUrlsFromString
Remove all Urls from a string- Parameters:
text
- the text to be clean- Returns:
- Urls removed string or "" if input text is null
-
isResumeDraftUrl
-
isPageCreationUrl
-
isPageEditUrl
-
isBlogPostCreationUrl
-
isBlogPostEditUrl
-
isTemplateCreationUrl
-
isTemplateEditUrl
-
isEditorLoaderUrl
-
isEditingUrl
-
getJdbcUrlQuery
Parses the query string from a JDBC URL.- Parameters:
jdbcUrl
- a string regarded a URI- Returns:
- the query string;
null
if empty or undefined
-
isSafeTitleForUrl
-
appendAmpersandOrQuestionMark
Appends an ampersand if the given string already contains a question mark, or a question mark otherwise.- Parameters:
str
- the string to prepare for adding a query param to.- Returns:
- the given string with a question mark
- Since:
- 8.6
-