5 unstable releases

0.3.1 Nov 22, 2023
0.3.0 Jun 5, 2023
0.2.0 Sep 8, 2022
0.1.1 Nov 9, 2021
0.1.0 Feb 2, 2018

#1883 in Parser implementations

Download history 113362/week @ 2024-12-17 56392/week @ 2024-12-24 78382/week @ 2024-12-31 163109/week @ 2025-01-07 148075/week @ 2025-01-14 137929/week @ 2025-01-21 141566/week @ 2025-01-28 159541/week @ 2025-02-04 155324/week @ 2025-02-11 163113/week @ 2025-02-18 153449/week @ 2025-02-25 161872/week @ 2025-03-04 181272/week @ 2025-03-11 165566/week @ 2025-03-18 154924/week @ 2025-03-25 128953/week @ 2025-04-01

657,763 downloads per month
Used in 541 crates (44 directly)

MIT/Apache

30KB
609 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());

No runtime deps