Added in API level 1

URLUtil

class URLUtil
kotlin.Any
   ↳ android.webkit.URLUtil

Summary

Public constructors

Public methods
static String!
composeSearchUrl(inQuery: String!, template: String!, queryPlaceHolder: String!)

Inserts the inQuery in the template after URL-encoding it.

static ByteArray!

static String!
guessFileName(url: String!, contentDisposition: String?, mimeType: String?)

Guesses canonical filename that a download would have, using the URL and contentDisposition.

static String!
guessUrl(inUrl: String!)

Cleans up (if possible) user-entered web addresses

static Boolean

static Boolean

static Boolean

static Boolean

static Boolean

static Boolean

static Boolean

static Boolean

static Boolean

static Boolean

static Boolean

static String!

Strips the url of the anchor.

Public constructors

URLUtil

URLUtil()

Public methods

composeSearchUrl

Added in API level 1
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.

decode

Added in API level 1
static fun decode(url: ByteArray!): ByteArray!

guessFileName

Added in API level 1
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

Added in API level 1
static fun guessUrl(inUrl: String!): String!

Cleans up (if possible) user-entered web addresses

isAboutUrl

Added in API level 1
static fun isAboutUrl(url: String!): Boolean
Return
Boolean true if the url is an about: url.

isAssetUrl

Added in API level 1
static fun isAssetUrl(url: String!): Boolean
Return
Boolean true if the url is an asset file.

isContentUrl

Added in API level 1
static fun isContentUrl(url: String!): Boolean
Return
Boolean true if the url is a content: url.

isCookielessProxyUrl

Added in API level 1
Deprecated in API level 15
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

Added in API level 1
static fun isDataUrl(url: String!): Boolean
Return
Boolean true if the url is a data: url.

isFileUrl

Added in API level 1
static fun isFileUrl(url: String!): Boolean
Return
Boolean true if the url is a local file.

isHttpUrl

Added in API level 1
static fun isHttpUrl(url: String!): Boolean
Return
Boolean true if the url is an http: url.

isHttpsUrl

Added in API level 1
static fun isHttpsUrl(url: String!): Boolean
Return
Boolean true if the url is an https: url.

isJavaScriptUrl

Added in API level 1
static fun isJavaScriptUrl(url: String!): Boolean
Return
Boolean true if the url is a javascript: url.

isNetworkUrl

Added in API level 1
static fun isNetworkUrl(url: String!): Boolean
Return
Boolean true if the url is a network url.

isValidUrl

Added in API level 1
static fun isValidUrl(url: String!): Boolean
Return
Boolean true if the url is valid.

stripAnchor

Added in API level 1
static fun stripAnchor(url: String!): String!

Strips the url of the anchor.