Commit fc2a960
spec: conform to latest WHATWG URL Pattern WPT test data
Refresh testdata/urlpatterntestdata.json from the current WPT snapshot
(365 cases, up from 313) and align the implementation with the new
expectations:
- createComponentMatchResult now bounds iteration by the group name
list length so user-provided regex groups (e.g. :foo((?<x>a))) no
longer index past the name list and panic. Groups without a name
are simply not exposed on result.Groups, matching WPT test 364.
- canonicalizeHostname: drop the broad reject-on-'/ ? # \\' guard.
The URL parser now canonicalizes those boundary chars correctly;
keep only the ':' check since without it "bad:hostname" would be
silently split into host + port.
- hostnameParser: drop WithFailOnValidationError so tab/LF/CR in a
hostname are stripped per the WHATWG URL spec instead of errored.
- canonicalizePort: rewritten to
1. skip leading ASCII tab / LF / CR and require the first
significant byte to be a digit (to reject "invalid80"),
2. always parse against a non-special scheme when no protocol
is supplied so the library doesn't collapse default ports
like 80/443 to empty,
3. remove the former "portValue != canonicalized" rejection
which also rejected valid canonicalizations like "8\t0" -> "80"
and "80x" -> "80" (state-override truncation).
All 365 WPT cases pass (2 skipped for advanced unicode features Go's
regexp engine does not support).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b0b64c3 commit fc2a960
3 files changed
Lines changed: 347 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
424 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
425 | 427 | | |
426 | | - | |
| 428 | + | |
427 | 429 | | |
428 | 430 | | |
429 | 431 | | |
| |||
462 | 464 | | |
463 | 465 | | |
464 | 466 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
476 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
477 | 482 | | |
478 | 483 | | |
479 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
480 | 492 | | |
481 | 493 | | |
482 | 494 | | |
483 | 495 | | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
494 | 499 | | |
495 | 500 | | |
496 | | - | |
| 501 | + | |
497 | 502 | | |
498 | 503 | | |
499 | 504 | | |
| |||
0 commit comments