2 releases

0.1.1 Nov 9, 2021
0.1.0 Feb 2, 2018
Download history 6648/week @ 2021-08-15 5562/week @ 2021-08-22 6052/week @ 2021-08-29 7687/week @ 2021-09-05 9849/week @ 2021-09-12 8772/week @ 2021-09-19 9256/week @ 2021-09-26 10216/week @ 2021-10-03 9984/week @ 2021-10-10 10798/week @ 2021-10-17 8833/week @ 2021-10-24 8762/week @ 2021-10-31 9293/week @ 2021-11-07 9644/week @ 2021-11-14 7144/week @ 2021-11-21 9977/week @ 2021-11-28

36,663 downloads per month
Used in 104 crates (12 directly)

MIT/Apache

26KB
539 lines

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());

lib.rs:

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());

Dependencies

w=a