Skip to content

Commit a6e63fe

Browse files
committed
Add metadata for the data-url crate
1 parent 56446b4 commit a6e63fe

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

data-url/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
name = "data-url"
33
version = "0.1.0"
44
authors = ["Simon Sapin <simon.sapin@exyr.org>"]
5+
description = "Processing of data: URL according to WHATWG’s Fetch Standard"
6+
repository = "https://github.com/servo/rust-url"
7+
license = "MIT OR Apache-2.0"
58

69
[dependencies]
710
matches = "0.1"

data-url/LICENSE-APACHE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE-APACHE

data-url/LICENSE-MIT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE-MIT

data-url/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# data-url
2+
3+
![crates.io](https://img.shields.io/crates/v/url.svg)
4+
![docs.rs](https://docs.rs/data-url/)
5+
6+
Processing of `data:` URLs in Rust according to the Fetch Standard:
7+
<https://fetch.spec.whatwg.org/#data-urls>
8+
but starting from a string rather than a parsed URL to avoid extra copies.
9+
10+
```rust
11+
use data_url::{DataUrl, mime};
12+
//!
13+
let url = DataUrl::process("data:,Hello%20World!").unwrap();
14+
let (body, fragment) = url.decode_to_vec().unwrap();
15+
//!
16+
assert_eq!(url.mime_type().type_, "text");
17+
assert_eq!(url.mime_type().subtype, "plain");
18+
assert_eq!(url.mime_type().get_parameter("charset"), Some("US-ASCII"));
19+
assert_eq!(body, b"Hello World!");
20+
assert!(fragment.is_none());
21+
```

0 commit comments

Comments
 (0)