fix(serve-static): normalize all backslashes in file paths, not just the first (#4962)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
`getFilePathWithoutDefaultDocument` converts backslash separators to slashes so the same path resolves consistently regardless of the separator style of the incoming request. The replace used a non-global regex (`/\/`), so only the FIRST backslash was converted: a path with multiple segments like `foo\bar\baz.txt` became `foo/bar\baz.txt` — mixed separators that resolve to the wrong file (or 404) on platforms that don't treat `\` as a separator. The adjacent comment (`foo\bar.txt => foo/bar.txt`) shows the intent was to normalize all of them. Fix: add the `g` flag (`/\/g`). Behaviour is unchanged for any path with zero or one backslash, so all existing tests pass; added a regression test covering a multi-segment path (with and without `root`) that returns the broken `foo/bar\baz.txt` before this change. tsc --noEmit clean; eslint + prettier clean.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Prodia Evolution Worker <evo@prodia.dev>
Diff stats
2 files+12 added−1 removed
- tests:+11 added−0 removed
- other:+1 added−1 removed