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

#2841 in Parser implementations

Download history 64112/week @ 2023-12-15 38138/week @ 2023-12-22 41863/week @ 2023-12-29 53545/week @ 2024-01-05 52220/week @ 2024-01-12 71985/week @ 2024-01-19 61954/week @ 2024-01-26 65634/week @ 2024-02-02 71654/week @ 2024-02-09 58382/week @ 2024-02-16 69047/week @ 2024-02-23 60163/week @ 2024-03-01 67059/week @ 2024-03-08 70935/week @ 2024-03-15 68177/week @ 2024-03-22 80461/week @ 2024-03-29

297,136 downloads per month
Used in 373 crates (41 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());

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

No runtime deps