feat: introduce CookiePath nominal type#598
Open
colincasey wants to merge 6 commits into
Open
Conversation
wjhsf
reviewed
May 1, 2026
Comment on lines
+3
to
+6
| import { defaultPathCases } from './data/defaultPathCases.js' | ||
| import { pathMatchCases } from './data/pathMatchCases.js' | ||
| import { permutePathCases } from './data/permutePathCases.js' | ||
|
|
Contributor
There was a problem hiding this comment.
Weird to have some test cases in a file and some inlined.
Contributor
Author
There was a problem hiding this comment.
The extracted files (defaultPathCases, permutePathCases, pathMatchCases) are the ones shared with the deprecated wrapper specs later in the stack — pulling them into data files lets both the CookiePath.* spec and the defaultPath/pathMatch/permutePath wrapper specs verify against the same corpus. The cases that stay inline (parse, parentPath) are unique to CookiePath and aren't reused, so there was no reason to extract them. I added header comments to each shared file noting this.
Replace the `CookiePath` const-object with flat `export function`s and a `ROOT` const, matching the rest of lib/cookie (defaultPath, pathMatch, permutePath) and lib/validators. The branded `CookiePath` type is unchanged, so internal consumers use it via `import * as CookiePath`. Mark the module `@internal`: CookiePath is a seam for migrating to stronger types behind the existing loose public API, not a new public surface. Also simplifies `match` (drops the redundant indexOf/startsWith duplication while preserving the identical-path early return), tidies `parse`/`permute`, removes pointless spread copies in the spec, and documents the shared test fixtures.
49e3601 to
79675d8
Compare
wjhsf
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CookiePathbranded type and const object withROOT,parse,parentPath,defaultPath,match, andpermute/-prefix invariant at compile time via a nominal type patternPart 1 of 3 for #582. Stacked on
master.Next: #cookie-path-deprecate-wrappers (deprecates existing wrapper functions)