public class ConversionUtils extends Object
| Constructor and Description |
|---|
ConversionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
escapeIllegalURLCharacters(String url) |
static String |
getEncodingFromContentType(String contentType)
Extract the encoding (charset) from the Content-Type, e.g.
|
static URL |
makeRelativeURL(URL baseURL,
String location)
Generate an absolute URL from a possibly relative location,
allowing for extraneous leading "../" segments.
|
static String |
removeSlashDotDot(String url)
collapses absolute or relative URLs containing '/..' converting
http://host/path1/../path2 to http://host/path2
or /one/two/../three to
/one/three |
static URI |
sanitizeUrl(URL url)
Checks a URL and encodes it if necessary,
i.e.
|
public static String getEncodingFromContentType(String contentType)
contentType - string from which the encoding should be extractednull, if none was found or
the charset is not supportedIllegalCharsetNameException - if the found charset is not supportedpublic static URL makeRelativeURL(URL baseURL, String location) throws MalformedURLException
URL.URL(URL, String) constructor does not remove these.baseURL - the base URL which is used to resolve missing protocol/host in the locationlocation - the location, possibly with extraneous leading "../"MalformedURLException - when the given URL is malformedpublic static String escapeIllegalURLCharacters(String url) throws Exception
url - String Url to escapeException - when given url leads to a malformed URL or URIpublic static URI sanitizeUrl(URL url) throws URISyntaxException
url - non-encoded URLURISyntaxException - if parts of the url form a non valid URIpublic static String removeSlashDotDot(String url)
http://host/path1/../path2 to http://host/path2
or /one/two/../three to
/one/threeurl - in which the '/..'s should be removedCopyright © 1998-2019 Apache Software Foundation. All Rights Reserved.