Parent: #140 Tracked by: #134, #163, #164
Symbols (URL cluster sub-slice 3 — origin length)
| Symbol | Home (packages/runtime/src/jsc/URL.zig @ 7ed99c02) | Bun C++ (upstream/src/jsc/bindings/BunString.cpp) |
|---|---|---|
URL__originLength | :167 — extern fn URL__originLength(latin1_slice: [*]const u8, len: usize) u32; (declared, un-wrapped: originFromSlice is omitted pending strings.firstNonASCII) | :569 — WTF::String from the latin-1 slice, WTF::URL, invalid → 0, else url.pathStart() |
Both pinned profiles declare the identical zig-side signature (latin1_slice: [*]const u8, len: usize) u32 (the C++ size_t return narrows to u32).
Last standalone URL-cluster symbol; after this slice only the DOMURL object-creation group (BunString__toURL/toJSDOMURL + WebCore__DOMURL__cast_/href_/pathname_/fileSystemPath) remains in the cluster.
Acceptance criteria
- Parse the latin-1 slice through the allocator-first
urlParsewith no base; empty/invalid (scheme-less) input returns 0, matching Bun's validity guard. pathStartis computed from the parsed parts so it exactly mirrorsurlSerialize's prefix emission:scheme:plus, when a host component is present,//+ userinfo (user[:pw]@, emitted only when non-empty) + host + (:portwhen set), plus the/.sentinel for a non-opaque path that begins with//. This is the byte offset where the path begins in the canonical serialization — i.e.url.origin.lengthfor tuple origins, and the scheme/authority prefix length otherwise.- The latin-1 slice is widened to WTF-8 before parsing (WTF 8-bit string semantics); non-ASCII bytes follow the parser's existing rules. A null slice returns 0 (zig-js sentinel where Bun dereferences unconditionally).
- Compiled runtime fixture covers: http with userinfo+port, default-port elision,
file:(empty authority present), opaque-path (mailto:), the//-led non-opaque sentinel case, invalid input → 0, null → 0; results cross-checked againstnew URL(...).origin.lengthwhere the JS getter exists (http/https) and against the serialized prefix elsewhere. Fixture symbol count 313 → 314. - Home inventory
311/431, Bun inventory304/421;bun-private-abi-audit+c-api-auditgreen; fullzig build testzero new failures (worktree baseline-vs-candidate against the same pinned base).
Design constraints
- No new parser machinery: reuse
urlParse+ the parts layout; the prefix-length arithmetic must not duplicate serialization logic beyond reading the same component fields. - Context-free: no realm, no exception channel — pure bytes in, length out.