android-components / mozilla.components.support.ktx.kotlin / kotlin.String

Extensions for kotlin.String

| Name | Summary | |—|—| | isEmail | fun String.isEmail(): Boolean | | isExtensionUrl | fun String.isExtensionUrl(): Boolean
Checks if this String is a URL of an extension page. | | isGeoLocation | fun String.isGeoLocation(): Boolean | | isPhone | fun String.isPhone(): Boolean | | isResourceUrl | fun String.isResourceUrl(): Boolean
Checks if this String is a URL of a resource. | | isSameOriginAs | fun String.isSameOriginAs(other: String): Boolean
Compares 2 URLs and returns true if they have the same origin, which means: same protocol, same host, same port. It will return false if either this or other is not a valid URL. | | isUrl | fun String.isUrl(): Boolean
Checks if this String is a URL. | | sanitizeFileName | fun String.sanitizeFileName(): String
Remove any unwanted character from string containing file name. For example for an input of “/../../../../../../directory/file.txt” you will get “file.txt” | | sanitizeURL | fun String.sanitizeURL(): String
Remove any unwanted character in url like spaces at the beginning or end. | | sha1 | fun String.sha1(): String
Calculates a SHA1 hash for this string. | | stripMailToProtocol | fun String.stripMailToProtocol(): String
Remove leading mailto from the string. For example for an input of “mailto:example@example.com” you will get “example@example.com” | | toDate | fun String.toDate(format: String, locale: Locale = Locale.ROOT): Date
Converts a String to a Date object.fun String.toDate(vararg possibleFormats: String = arrayOf( "yyyy-MM-dd'T'HH:mm", "yyyy-MM-dd", "yyyy-'W'ww", "yyyy-MM", "HH:mm" )): Date?
Tries to convert a String to a Date using a list of possibleFormats. | | toNormalizedUrl | fun String.toNormalizedUrl(): String | | tryGetHostFromUrl | fun String.tryGetHostFromUrl(): String
Tries to parse and get host part if this String is valid URL. Otherwise returns the string. | | urlEncode | fun String.urlEncode(): String
Translates the string into {@code application/x-www-form-urlencoded} string. |