URLUtil
class URLUtil
Summary
Public constructors
Public methods
composeSearchUrl
static fun composeSearchUrl(
inQuery: String!,
template: String!,
queryPlaceHolder: String!
): String!
Inserts the inQuery
in the template
after URL-encoding it. The encoded query will replace the queryPlaceHolder
.
guessFileName
static fun guessFileName(
url: String!,
contentDisposition: String?,
mimeType: String?
): String!
Guesses canonical filename that a download would have, using the URL and contentDisposition.
File extension, if not defined, is added based on the mimetype.
The contentDisposition
argument will be treated differently depending on targetSdkVersion.
- For targetSDK versions <
VANILLA_ICE_CREAM
it will be parsed based on RFC 2616.
- For targetSDK versions >=
VANILLA_ICE_CREAM
it will be parsed based on RFC 6266.
In practice, this means that from
VANILLA_ICE_CREAM
, this method will be able to parse
filename*
directives in the
contentDisposition
string.
The function also changed in the following ways in VANILLA_ICE_CREAM
:
- If the suggested file type extension doesn't match the passed
mimeType
, the method will append the appropriate extension instead of replacing the current extension.
- If the suggested file name contains a path separator (
"/"
), the method will replace this with the underscore character ("_"
) instead of splitting the result and only using the last part.
Parameters |
url |
String!: Url to the content |
contentDisposition |
String?: Content-Disposition HTTP header or null |
mimeType |
String?: Mime-type of the content or null |
Return |
String! |
suggested filename |
guessUrl
static fun guessUrl(inUrl: String!): String!
Cleans up (if possible) user-entered web addresses
isAboutUrl
static fun isAboutUrl(url: String!): Boolean
Return |
Boolean |
true if the url is an about: url. |
isAssetUrl
static fun isAssetUrl(url: String!): Boolean
Return |
Boolean |
true if the url is an asset file. |
isContentUrl
static fun isContentUrl(url: String!): Boolean
Return |
Boolean |
true if the url is a content: url. |
isCookielessProxyUrl
static fun isCookielessProxyUrl(url: String!): Boolean
Deprecated: Cookieless proxy is no longer supported.
Return |
Boolean |
true if the url is a proxy url to allow cookieless network requests from a file url. |
isDataUrl
static fun isDataUrl(url: String!): Boolean
Return |
Boolean |
true if the url is a data: url. |
isFileUrl
static fun isFileUrl(url: String!): Boolean
Return |
Boolean |
true if the url is a local file. |
isHttpUrl
static fun isHttpUrl(url: String!): Boolean
Return |
Boolean |
true if the url is an http: url. |
isHttpsUrl
static fun isHttpsUrl(url: String!): Boolean
Return |
Boolean |
true if the url is an https: url. |
isJavaScriptUrl
static fun isJavaScriptUrl(url: String!): Boolean
Return |
Boolean |
true if the url is a javascript: url. |
isNetworkUrl
static fun isNetworkUrl(url: String!): Boolean
Return |
Boolean |
true if the url is a network url. |
stripAnchor
static fun stripAnchor(url: String!): String!
Strips the url of the anchor.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-04 UTC.
[null,null,["Last updated 2024-04-04 UTC."],[],[]]