KiteDataUrl

The content of a data: URL (RFC 2397): its media type and its bytes. A document carries a small resource inside itself this way, an image or a font as Base64, or an SVG percent-encoded:

val url = KiteDataUrl.decode("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E")
url?.mediaType // "image/svg+xml"
url?.bytes // the SVG's UTF-8 bytes

decode follows the data URL processor of the WHATWG Fetch standard: the body is percent-decoded, then Base64-decoded when the header ends in ;base64, forgiving white space and missing padding.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The decoded content.

Link copied to clipboard

The media type without its parameters, lower-cased: image/svg+xml for image/svg+xml;charset=utf-8.

Link copied to clipboard

The media type with its parameters, as the URL gives it, text/plain;charset=US-ASCII when it gives none.