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

#982 in Web programming

Download history 70958/week @ 2024-08-04 82992/week @ 2024-08-11 84216/week @ 2024-08-18 99582/week @ 2024-08-25 95094/week @ 2024-09-01 94637/week @ 2024-09-08 83511/week @ 2024-09-15 101775/week @ 2024-09-22 115161/week @ 2024-09-29 91910/week @ 2024-10-06 119067/week @ 2024-10-13 115172/week @ 2024-10-20 122808/week @ 2024-10-27 107778/week @ 2024-11-03 139315/week @ 2024-11-10 143277/week @ 2024-11-17

520,394 downloads per month
Used in 472 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