public class UrlOperations extends Object
Modifier and Type | Field and Description |
---|---|
static String[] |
ALL_SCHEMES
array of static Strings for all "known" schemes
|
static String |
DEFAULT_SCHEME
Default scheme to assume if unspecified.
|
static String |
DNS_SCHEME
ARC/WARC specific DNS resolution record.
|
static String |
FTP_SCHEME
FTP
|
static String |
HTTP_SCHEME
HTTP
|
static String |
HTTPS_SCHEME
HTTPS
|
static String |
MMS_SCHEME
MMS
|
static char |
PATH_START
character which delimits the path from the authority in a... in some
URLs.
|
static char |
PORT_SEPARATOR
character separating host from port within a URL authority
|
static String |
RTSP_SCHEME
RTSP
|
static String |
WAIS_SCHEME
go brewster
|
Constructor and Description |
---|
UrlOperations() |
Modifier and Type | Method and Description |
---|---|
static String |
computeIdentityUrl(WaybackRequest wbRequest)
build replay Archival-URL for the same capture as request
wbRequest , with identity-context (id_ ) flag on. |
static String |
fixupHTTPUrlWithOneSlash(String orig) |
static String |
fixupScheme(String url)
fixes up malformed scheme part.
|
static String |
getUrlParentDir(String url)
Find and return the parent directory of the URL argument
|
static String |
getURLPath(String url)
Attempt to extract the path component of a url String argument.
|
static boolean |
isAuthority(String authString)
Tests if the String argument looks like it could be a legitimate
authority fragment of a URL, that is, is it an IP address, or, are the
characters legal in an authority, and does the string end with a legal
TLD.
|
static String |
resolveUrl(String baseUrl,
String url)
Resolve URL, but return a minimally escaped version in case of
error
|
static String |
resolveUrl(String baseUrl,
String url,
String defaultValue)
Resolve a possibly relative url argument against a base URL.
|
static int |
schemeToDefaultPort(String scheme)
Return the default port for the scheme String argument, if known.
|
static String |
stripDefaultPortFromUrl(String url)
Attempt to strip default ports out of URL strings.
|
static String |
stripURLScheme(String url)
Attempt to extract the path component of a url String argument.
|
static String |
urlToHost(String url)
Attempt to extract the hostname component of an absolute URL argument.
|
static String |
urlToScheme(String url)
Attempt to find the scheme (http://, https://, etc) from a given URL.
|
static String |
urlToUserInfo(String url)
Extract userinfo from the absolute URL argument, that is, "username@", or
"username:password@" if present.
|
public static final String DNS_SCHEME
public static final String HTTP_SCHEME
public static final String HTTPS_SCHEME
public static final String FTP_SCHEME
public static final String MMS_SCHEME
public static final String RTSP_SCHEME
public static final String DEFAULT_SCHEME
public static final String WAIS_SCHEME
public static final String[] ALL_SCHEMES
public static final char PORT_SEPARATOR
public static final char PATH_START
public static boolean isAuthority(String authString)
authString
- String representation of a fragment of a URLpublic static String resolveUrl(String baseUrl, String url)
baseUrl
- the base URL against which the url should be resolvedurl
- the URL, possibly relative, to make absolute.public static String resolveUrl(String baseUrl, String url, String defaultValue)
baseUrl
- the base URL against which the url should be resolvedurl
- the URL, possibly relative, to make absolute.defaultValue
- The default value to return if the supplied values can't be resolved.public static String urlToScheme(String url)
url
- URL String to parse for a scheme.public static int schemeToDefaultPort(String scheme)
scheme
- String scheme, including '://', as in, "http://", "ftp://"public static String getURLPath(String url)
url
- the URL which may contain a path, sans scheme.public static String stripURLScheme(String url)
url
- the URL which may contain a path, sans scheme.public static String stripDefaultPortFromUrl(String url)
url
- the original URL possibly including a portpublic static String fixupHTTPUrlWithOneSlash(String orig)
orig
- String containing a URL, possibly beginning with "http:/".fixupScheme(java.lang.String)
public static String fixupScheme(String url)
currently supports fixing missing second slash for protocols
http
, https
, ftp
, rtsp
and
mms
. For example fixing http:/
to https://
url
- URL to be checked and fixedurl
if not fix is required.public static String urlToHost(String url)
url
- the url String from which to extract the hostnamepublic static String urlToUserInfo(String url)
url
- the URL from which to extract the userinfopublic static String getUrlParentDir(String url)
url
- to find the parent directory ofpublic static String computeIdentityUrl(WaybackRequest wbRequest)
wbRequest
, with identity-context (id_
) flag on.
REFACTOR: move this method to ArchivalUrl
.
wbRequest
- requested capture and URL scheme info.Copyright © 2005–2015 IIPC. All rights reserved.