Skip to content

What it does

  • The WHATWG URL Standard: parsing against a base, every getter and setter the URL interface has, and origins.
  • URLSearchParams.
  • Hosts, IDNA (UTS #46) and Punycode, with Unicode 18.0’s tables and normalization built in.
  • An API shaped like JavaScript’s, so url.pathname() here is url.pathname there.

Add it

In Rust, add parsec-url (0.3.1 on crates.io); the library inside isparsec_url. Rust only. The other bindings resolve links through the HTML parser, not this API.

parsec-url 0.3.1, from its documentation
use parsec_url::Url;

let base = Url::parse("https://example.com/a/b?x=1").unwrap();
let mut url = Url::parse_with_base("../c?q=two words#top", &base).unwrap();
assert_eq!(url.href(), "https://example.com/c?q=two%20words#top");

let mut params = url.search_params();
params.append("page", "2");
url.set_search_params(&params);
assert_eq!(url.search(), "?q=two+words&page=2");

That's the first example in the crate's own documentation at the v0.3.1 tag, unchanged.cargo test runs it on every change, so it compiles and passes against the release you'd install. The API reference on docs.rs has the rest, and the getting started guide goes step by step.

Checked against the standards

These counts are the conformance baseline on Parsec's main branch, read when this page was built. Each release has to match or beat them: a suite that passes fewer cases, or fails more, stops the release.

SuitePassFailSkipped
web-platform-tests URL parsing90400
web-platform-tests URL origins42100
web-platform-tests URL setters28400
web-platform-tests ToASCII2610522
web-platform-tests IDNA2,67501
web-platform-tests IDNA, removed cases2000
Unicode normalization20,17200

Standards has every suite, where its data comes from, and why the failures and skips are what they are.

Where it stops

  • web-platform-tests has one file of URL cases only JavaScript can express, every one a lone surrogate. A Rust string can’t hold one, so they don’t run.

The URL page in the docs goes through the API, the limits and the conformance details in full.