Repository navigation
fix(utils): make normalizePath idempotent by globally collapsing repeated slashes (#161) - #167
Open
deus-intus wants to merge 1 commit into
Open
deus-intus wants to merge 1 commit into
deus-intus wants to merge 1 commit into
Conversation
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.
Fixes #161
Problem
On main,
normalizePathonly collapsed the first repeated slash group because the regex lacked the global (g) flag:normalizePath("a///b///c.txt")returned"a/b///c.txt"instead of"a/b/c.txt".normalizePath("a//b//c//d")returned"a/b//c//d"instead of"a/b/c/d".normalizePathmultiple times changed the result, causing non-idempotent behavior during database storage and lookups.Solution
Added the global
/gflag to the slash collapse regex inlib/utils/normalize-path.ts:Verification
Added
tests/normalize-path.test.tsverifying:Ran full test suite with Bun (
bun test): all 33 tests across 10 files pass cleanly.