Guillaume Gomez 86730f1653 Add `--generate-link-to-definition` option when building on docs.rs (#858) hace 3 años
..
src e4dbb436e6 Implement std::error::Error for InvalidBase64 (#856) hace 3 años
tests 8d72494c82 Align mime type parser to spec hace 4 años
Cargo.toml 86730f1653 Add `--generate-link-to-definition` option when building on docs.rs (#858) hace 3 años
LICENSE-APACHE a6e63fed24 Add metadata for the data-url crate hace 8 años
LICENSE-MIT a6e63fed24 Add metadata for the data-url crate hace 8 años
README.md 49bea1e876 Fix data-url README hace 8 años

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