data-url

Crates.iodata-url
lib.rsdata-url
version0.3.1
sourcesrc
created_at2018-02-02 09:20:35.995542
updated_at2023-11-22 19:06:43.105373
descriptionProcessing of data: URL according to WHATWG’s Fetch Standard
homepage
repositoryhttps://github.com/servo/rust-url
max_upload_size
id49319
size125,874
cargo publish (github:servo:cargo-publish)

documentation

README

data-url

crates.io docs.rs

Processing of data: URLs in Rust 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());
Commit count: 1338

cargo fmt