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

#1018 in Web programming

Download history 73268/week @ 2024-08-14 93788/week @ 2024-08-21 93667/week @ 2024-08-28 102981/week @ 2024-09-04 84537/week @ 2024-09-11 98944/week @ 2024-09-18 97747/week @ 2024-09-25 111157/week @ 2024-10-02 96106/week @ 2024-10-09 122845/week @ 2024-10-16 115008/week @ 2024-10-23 120300/week @ 2024-10-30 102103/week @ 2024-11-06 166882/week @ 2024-11-13 130410/week @ 2024-11-20 92339/week @ 2024-11-27

510,745 downloads per month
Used in 475 crates (43 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