1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! A URL crate that's better than the one provided by Servo.
//!
//! Licensed under the Affero General Public License V3 or later
//!
//! <https://www.gnu.org/licenses/agpl-3.0.html>
//!
//! <https://github.com/Scripter17/url-cleaner>
//!
//! ## Performance
//!
//! See [`better-url-bench`](https://github.com/Scripter17/url-cleaner/tree/main/better-url-bench) for performance details.
//!
//! TL;DR: Better URL blows Servo's URL crate (`url`) out of the water (as of their 2.5.8), and is a respectable fraction of the speed of Ada's URL crate (`ada_url`) (as of their 4.0.0).
//!
//! ## Parsing from bytes
//!
//! [`BetterUrl`] as well as the various [`parts`] types have constructors not just from strings but also from arbitrary byte sequences.
//!
//! For byte sequences that happen to be UTF-8, the behavior is identical, but for byte sequences that aren't UTF-8, *UTF-8 validity is not checked* unless and until needed.
//!
//! To be clear, this is sound because all URL parts are converted into ASCII anyway, and those ASCII values are valid input.
//!
//! This doesn't let you reach invalid states, it just lets you reach valid states slightly faster.
//!
//! In the future I may add a feature flag to enforce UTF-8 validity in bytes constructors.
//!
//! ```
//! use better_url::prelude::*;
//!
//! assert_eq!(Ipv4Host::new(b"127.0.0.%E2\x91%A0").unwrap(), "127.0.0.1");
//!
//! assert_eq!(SpecialQuery::new(b"\xFF"), "%FF");
//!
//! assert_eq!(BetterUrl::new(b"https://example.com/\xFF?\xFF#\xFF").unwrap(), "https://example.com/%FF?%FF#%FF");
//! ```
pub use *;
/// Prelude module for importing everything here better.