David Sherret ffca1eff75 chore: fix clippy errors on main (#1019) 1 年之前
..
src ffca1eff75 chore: fix clippy errors on main (#1019) 1 年之前
tests e654efb9c1 Fix non-base64 data URLs with % character not followed by hex digits (#797) 2 年之前
Cargo.toml ebd5cfbf6f `no_std`support for the `url` crate (#831) 1 年之前
LICENSE-APACHE a6e63fed24 Add metadata for the data-url crate 8 年之前
LICENSE-MIT a6e63fed24 Add metadata for the data-url crate 8 年之前
README.md 49bea1e876 Fix data-url README 8 年之前

README.md

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