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

#679 in Web programming

Download history 114180/week @ 2024-10-21 123393/week @ 2024-10-28 107753/week @ 2024-11-04 139273/week @ 2024-11-11 150968/week @ 2024-11-18 107228/week @ 2024-11-25 146392/week @ 2024-12-02 149059/week @ 2024-12-09 132771/week @ 2024-12-16 57657/week @ 2024-12-23 69188/week @ 2024-12-30 156555/week @ 2025-01-06 155117/week @ 2025-01-13 133777/week @ 2025-01-20 142590/week @ 2025-01-27 150372/week @ 2025-02-03

591,164 downloads per month
Used in 509 crates (45 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