[Bug]: Default cookie path includes an extra trailing slash

オープン 初心者向け
#44,340 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
networking

調査の方向性

ペイロードは packages/playwright-core/src/server/network.ts を指しており、そこではデフォルトの Cookie パスが url.pathname.substring(0, url.pathname.lastIndexOf('/') + 1) で導出されます。まずそのブロックを読み、同じファイル内の context.addCookies からどのように到達するかを確認してから、/foo/bar、/foo、/ のようなケースについて RFC 6265 の default-path アルゴリズムと比較してください。完了条件は、明示的な path がないパスが /foo/bar に対して /foo を返すことであり、テストスイート内の既存の addCookies テストの隣に回帰テストが追加され、Cookie の spec が通ることです。

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

説明

Version

Playwright main branch.

Steps to reproduce
const url = server.PREFIX + '/foo/bar';

await context.addCookies([{
  url,
  name: 'default-path',
  value: 'test',
}]);

const cookies = await context.cookies();
console.log(cookies.find(cookie => cookie.name === 'default-path')?.path);
Expected behavior

When a cookie is added using URL /foo/bar without an explicit path, the default cookie path should be /foo, excluding the trailing slash.

Actual behavior

The current implementation in packages/playwright-core/src/server/network.ts calculates the path using:

copy.path = url.pathname.substring(0, url.pathname.lastIndexOf('/') + 1);

For /foo/bar, this produces /foo/, including the trailing slash.

Additional context

According to the cookie default-path algorithm, the expected path is /foo. The trailing slash can affect cookie path matching.

Environment
OS: Ubuntu Linux
Node.js: v22.23.5
Playwright version: 1.66.0-next (main branch)
Browser: Chromium
主要言語
TypeScript
スター
100k
フォーク
6.9k
平均マージ
16時間 18分
マージ済み PR(30日)
281

環境構築

はじめの一歩

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

microsoft/playwright のほかの issue

microsoft/playwright の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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