nodejs / nodejs/node

url: URLPattern.exec() does not preserve capture group declaration order

オープン
#64,734 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず node:url の URLPattern.exec() を使って再現を実行し、結果の pathname.groups オブジェクトを調べます。名前付きグループがどのように挿入されるかを特定するため、URLPattern の実装とそのテストを追跡します;完了の条件は、グループが宣言順に現れ、名前によるアクセスも可能なままになっており、その例に対するリグレッションカバレッジがあることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
api
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
68/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。