Expand description
Processing of data:
URLs according to the Fetch Standard:
https://fetch.spec.whatwg.org/#data-urls
but starting from a string rather than a parsed URL to avoid extra copies.
use data_url::{DataUrl, mime};
let url = DataUrl::process("data:,Hello%20World!").unwrap();
let (body, fragment) = url.decode_to_vec().unwrap();
assert_eq!(url.mime_type().type_, "text");
assert_eq!(url.mime_type().subtype, "plain");
assert_eq!(url.mime_type().get_parameter("charset"), Some("US-ASCII"));
assert_eq!(body, b"Hello World!");
assert!(fragment.is_none());
Modulesยง
Macrosยง
- require ๐
Structsยง
- The URLโs fragment identifier (after
#
)
Enumsยง
Functionsยง
- decode_
with_ ๐base64 decode_without_base64()
composed with https://infra.spec.whatwg.org/#isomorphic-decode composed with https://infra.spec.whatwg.org/#forgiving-base64-decode. - This is https://url.spec.whatwg.org/#string-percent-decode while also:
- parse_
header ๐ - percent_
encode ๐ - remove_
base64_ ๐suffix None: no base64 suffix