url-lite
Port of the URL parser from nodejs/http-parser to Rust
Features
#[no_std]
- No heap allocations, returns a struct of
&str
- Never panics(tested by dtolnay/no-panic)
Installation
Example
use ;
// Note that ParseError doesn't implement the Error trait unless the `unstable`
// feature is enabled
assert!
let input = "https://usr:pass@example.com:8080/some%20path?foo=bar#zzz";
let url = parse.expect;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Features
unstable
- Implementscore::error::Error
forParseError
. Requires nightly due to error_in_core
Caveats
Although this is a port of the URL parser from http-parser and it passes all the tests, it has not been used in production. It is also not a generic parser, may not support all URLs, only returns slices, and performs no decoding.
If you need a robust URL parser and are okay with std/alloc dependency, use servo/rust-url instead.