Skip to content

feat(url): parsec-url failed 875 WPT cases and trailed Ada on speed - #86

Merged
jamesconwaydev merged 5 commits into
mainfrom
url-own-parser
Nov 19, 2026
Merged

jamesconwaydev merged 5 commits into
mainfrom
url-own-parser

Conversation

@jamesconwaydev

@jamesconwaydev jamesconwaydev commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

parsec-url wrapped the url and idna crates. Against WPT at 6dac967 they pass 3,690 of 4,565 URL cases; 795 of the 875 failures are the June 2026 rule that keeps an ASCII domain as written, and the rest are file: hosts before drive letters, blob: origins, spaces at the end of opaque paths, ^ in paths and a few more. On the 83,113 links in the bench pages Ada was 1.25 times as fast as Parsec. This is #82.

Change

  • A WHATWG URL parser of Parsec's own in crates/parsec-url, behind the same API, written from the URL Standard's current text: the state machine, host parsing (domains, IPv4 with the ends-in-a-number rule, IPv6, opaque hosts), the percent-encode sets, the setters as the basic URL parser with a state override, origins including blob:, and application/x-www-form-urlencoded.
  • A parsed Url is one String and the offsets of its components, written as it's parsed, the way Ada's url_aggregator is. Runs that need no encoding are copied whole, and an ASCII host is lowercased in one pass with no IDNA, which since June 2026 is all the standard asks of it.
  • IDNA is UTS CSS (M7) #46 with the standard's options (nontransitional, CheckBidi and CheckJoiners on), Punycode, and the RFC 5893 Bidi and RFC 5892 ContextJ rules.
  • parsec_url::normalize::{nfc, nfd}: decomposition, canonical ordering, composition with the exclusions, Hangul by arithmetic. It's M6's Unicode normalization item.
  • scripts/gen-tables.py writes src/tables.rs from the Unicode data files, deterministically and rustfmt'd. It uses Unicode 18.0, not 17.0: WPT's IdnaTestV2.json at the pinned commit is generated from 18.0, and seven of its cases use code points 18.0 added.
  • known-failures.txt is gone and the WPT runner fails on any failure. url and idna are no longer dependencies of parsec-url; they stay in Cargo.lock through crates/parsec.
  • Url::as_url() and the url::Url conversions go with the crate. ParseError and Host are this crate's own types, with the same names. domain_to_unicode now returns a domain with an error unchanged, as the standard's domain to Unicode does.
  • README and ROADMAP: M6 is done.

Tests

  • WPT URL: 4,565 passed, 0 failed (urltestdata 904, origins 421, setters 284, toascii 261, IdnaTestV2 2,675, IdnaTestV2-removed 20).
  • tests/normalization.rs runs all of Unicode 18.0's NormalizationTest.txt, now vendored with its licence: 20,171 lines checked ten ways each, plus part 1's rule over every scalar value. All pass.
  • Bench, cargo run --release --manifest-path bench/Cargo.toml -- urls: two runs at one-minute load under 3. Real links (83,113): Parsec 104 and 107 ns, Ada 141 and 142, Lexbor 239 and 243, so 1.33x Ada and 2.28x Lexbor; all three agree on every href. WPT inputs (904): Parsec 124, Ada 145 and 157, Lexbor 180 and 183; Ada agrees on all 634 that parse, Lexbor differs on 16. The url crate took 181 ns on the real links.
  • A random-input run of 300,000 strings, parsed with and without bases and put through every setter, found no panic and no href that reparses differently.
  • cargo fmt, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace and cargo deny check pass.

Closes #82

parsec-url wrapped the url and idna crates, which pass 3,690 of the
4,565 web-platform-tests URL cases (795 of the failures are the June
2026 rule that keeps an ASCII domain as written) and take 1.25 times
as long as Ada on the links in the benchmark pages.

It now has a WHATWG URL parser of its own behind the same API, written
from the standard's current text: the state machine, host parsing
(domains, IPv4 with the ends-in-a-number rule, IPv6, opaque hosts),
the percent-encode sets, the setters, origins including blob:, and
application/x-www-form-urlencoded. A parsed URL is one string and the
offsets of its components, written as it's parsed.

IDNA is UTS #46 with the URL Standard's options, Punycode, and the
RFC 5893 Bidi and RFC 5892 ContextJ rules. NFC and NFD come from the
character data and are public as parsec_url::normalize. The tables are
generated by scripts/gen-tables.py from Unicode 18.0, the version the
pinned WPT IDNA tests come from.

Every WPT case passes, so known-failures.txt is gone and the runner
fails on any failure. NormalizationTest.txt is vendored and runs in
cargo test. url and idna are no longer dependencies of parsec-url;
they stay in the lockfile through crates/parsec.

Closes #82
scripts/check-headers.sh wants every tracked Rust file to start with
the SPDX and copyright lines; gen-tables.py now writes them.
Comment thread crates/parsec-url/src/lib.rs Fixed
Comment thread crates/parsec-url/src/lib.rs Fixed
M6 is done: all 4,565 WPT URL cases pass, NormalizationTest passes,
and on the 83,113 links in the bench pages Parsec takes 107 ns a URL
to Ada's 142 and Lexbor's 243, measured twice at load under 3.
set_userinfo took a bool named password, so CodeQL flagged the true
and false passed to it as hard-coded passwords. It now takes a function
that picks the username or password part.
# Conflicts:
#	README.md
@jamesconwaydev
jamesconwaydev merged commit f02058a into main Nov 19, 2026
32 checks passed
@jamesconwaydev
jamesconwaydev deleted the url-own-parser branch November 19, 2026 03:57
@jamesconwaydev jamesconwaydev mentioned this pull request Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A URL parser of Parsec's own, passing what url fails and beating Ada

2 participants