Package org.craftercms.commons.lang
Class UrlUtils
- java.lang.Object
-
- org.craftercms.commons.lang.UrlUtils
-
public class UrlUtils extends Object
Utility methods for paths and URLs.- Author:
- avasquez
-
-
Field Summary
Fields Modifier and Type Field Description static String
RANGE_HEADER_FORMAT
static String
RANGE_HEADER_NAME
static String
RANGE_NO_END_HEADER_FORMAT
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
addParam(String url, String name, String value, String charset)
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
concat(String mainUrl, String relativeUrl)
Concats two urls, adding any "/" needed between them.static String
concat(String mainUrl, String... relativeUrls)
Concats two or more urls, adding any "/" needed between them.
-
-
-
Field Detail
-
RANGE_HEADER_NAME
public static final String RANGE_HEADER_NAME
- See Also:
- Constant Field Values
-
RANGE_HEADER_FORMAT
public static final String RANGE_HEADER_FORMAT
- See Also:
- Constant Field Values
-
RANGE_NO_END_HEADER_FORMAT
public static final String RANGE_NO_END_HEADER_FORMAT
- See Also:
- Constant Field Values
-
-
Method Detail
-
concat
public static String concat(String mainUrl, String relativeUrl)
Concats two urls, adding any "/" needed between them.- Parameters:
mainUrl
- the main urlrelativeUrl
- the relative url- Returns:
- mainPath + relativeUrl
-
concat
public static String concat(String mainUrl, String... relativeUrls)
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
public static String addQueryStringFragment(String url, String fragment)
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
-
-