url: URLPattern.exec() does not preserve capture group declaration order
未关闭
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 272
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用 node:url 的 URLPattern.exec() 运行复现,并检查生成的 pathname.groups 对象。跟踪 URLPattern 的实现及其测试,以确定命名组是如何插入的;完成标准是这些组按声明顺序出现,同时仍可通过名称访问,并为该示例提供回归覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 68/100