Package org.craftercms.commons.lang
Class UrlUtils
java.lang.Object
org.craftercms.commons.lang.UrlUtils
Utility methods for paths and URLs.
- Author:
- avasquez
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Adds a query string param to the URL, adding a '?' if there's no query string yet.static String
addQueryStringFragment
(String url, String fragment) Adds a query string fragment to the URL, adding a '?' if there's no query string yet.static String
cleanUrlForLog
(String url) Clean a url for logging purposes.static String
Concats two urls, adding any "/" needed between them.static String
Concats two or more urls, adding any "/" needed between them.
-
Field Details
-
RANGE_HEADER_NAME
- See Also:
-
RANGE_HEADER_FORMAT
- See Also:
-
RANGE_NO_END_HEADER_FORMAT
- See Also:
-
-
Method Details
-
concat
Concats two urls, adding any "/" needed between them.- Parameters:
mainUrl
- the main urlrelativeUrl
- the relative url- Returns:
- mainPath + relativeUrl
-
concat
Concats two or more urls, adding any "/" needed between them.- Parameters:
mainUrl
- the main urlrelativeUrls
- the array of relative urls- Returns:
- mainPath + relativeUrls...
-
addParam
public static String addParam(String url, String name, String value, String charset) throws UnsupportedEncodingException Adds a query string param to the URL, adding a '?' if there's no query string yet.- Parameters:
url
- the URLname
- the name of the paramvalue
- the value of the paramcharset
- the charset to encode the param key/value with- Returns:
- the URL with the query string param appended
- Throws:
UnsupportedEncodingException
-
addQueryStringFragment
Adds a query string fragment to the URL, adding a '?' if there's no query string yet.- Parameters:
url
- the URLfragment
- the query string fragment- Returns:
- the URL with the query string fragment appended
-
cleanUrlForLog
Clean a url for logging purposes. It truncates the url to 2000 characters and removes any line feeds or carriage returns.- Parameters:
url
- the url to clean- Returns:
- the cleaned url
-