public class UrlHelper extends Object
| Constructor and Description |
|---|
UrlHelper() |
| Modifier and Type | Method and Description |
|---|---|
static String |
addProtocol(String url)
Checks whether a URL specifies its protocol, prepending http if it does not.
|
static String |
getDomain(String url)
Gets the domain from
url. |
static String |
getDomainChecked(String url)
Gets the domain from
uri, and throws an exception if it's not a valid uri. |
static List<String> |
getDomainLevels(String host)
Gets the domain levels for a host.
|
static String |
getPath(String url)
Gets the path from
url. |
static String |
stripUrlParameters(String url)
Strips URL parameters from a url.
|
static String |
stripUrlParameters(URL url)
Convenience method that calls #stripUrlParameters(String) for a URL.
|
public static String getDomain(String url)
url.url - A url.null if the url is invalid.public static String getDomainChecked(String url) throws URISyntaxException
uri, and throws an exception if it's not a valid uri.url - A url.null if the host is undefined.URISyntaxException - if url is not a valid URIpublic static String getPath(String url)
url.url - A url.null if the url is invalid.public static String stripUrlParameters(String url)
url - The URL to strip parameters from.public static String stripUrlParameters(URL url)
url - The URL to strip parameters from.public static String addProtocol(String url)
url - The URL to fix.public static List<String> getDomainLevels(String host)
host - The host to peel subdomains off from.