Skip to content

fix: collapse every repeated slash group in normalizePath - #162

Open
ccelomary wants to merge 1 commit into
tscircuit:mainfrom
ccelomary:fix/normalize-path-161
Open

ccelomary wants to merge 1 commit into
tscircuit:mainfrom
ccelomary:fix/normalize-path-161

Conversation

@ccelomary

Copy link
Copy Markdown

normalizePath("a///b///c.txt") currently returns a/b///c.txt, and normalizing that result again changes it. Make the forward-slash replacement global so every repeated group collapses in one call, keeping storage and lookup normalization consistent.

Add nine Bun unit tests covering repeated internal groups, leading/trailing groups, idempotence, ordinary paths, empty/root/all-slash input, and Windows separators. Against untouched upstream commit bab714d, these tests produce 4 passes and 5 failures; with the fix, all nine pass.

Closes #161.

Validation

Executed against these exact files in Ubuntu/WSL with Bun 1.4.3 and the repository's frozen lockfile:

  • bun test — 38 passed, 0 failed
  • bun run format:check — passed
  • bun run build — passed (bundle, CLI, and declarations)
  • bunx tsc --noEmit — passed
  • git diff --check — passed

Windows also passes tests, formatting with LF checkout, and TypeScript. The Windows build fails because Winterspec emits backslash-containing import paths; the same error reproduces on untouched upstream bab714d. No build-system changes are included.

Related work

Open PR #133 contains the same one-line normalization fix alongside route regression coverage and a test-server change. This PR overlaps that fix and offers the smaller two-file change with focused utility coverage for #161.

Prepared and verified with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

normalizePath is not idempotent when a path has multiple repeated slash groups

1 participant