url: URLPattern.exec() does not preserve capture group declaration order
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
Version
latest main branch
Platform
7.1.4-arch1-1
Subsystem
url
What steps will reproduce the bug?
const assert = require('node:assert');
const { URLPattern } = require('node:url');
const pattern = new URLPattern({
pathname: '/:one/:two/:three',
});
const result = pattern.exec('https://example.com/a/b/c');
console.log(Object.entries(result.pathname.groups));
How often does it reproduce? Is there a required condition?
Every
What is the expected behavior? Why is that the expected behavior?
[
['one', 'a'],
['two', 'b'],
['three', 'c'],
]
URLPattern.exec() may expose named capture groups in an order different from their declaration order.
The captured values remain accessible by name, but the incorrect property insertion order is observable through Object.keys(), Object.values(), Object.entries(), object spread, and JSON serialization.
What do you see instead?
[
['three', 'c'],
['two', 'b'],
['one', 'a'],
]
Additional information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproduction with node:url's URLPattern.exec() and inspect the resulting pathname.groups object. Trace the URLPattern implementation and its tests to identify how named groups are inserted; done means the groups appear in declaration order while remaining accessible by name, with regression coverage for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100