Open
Conversation
…b matching
glob-slasher (v1.0.1, 2014, EOL) depends on glob-slash, which calls
path.normalize(path.join('/', value)). On Windows, path.normalize converts
forward slashes to backslashes, breaking glob pattern matching entirely —
e.g. /api/** becomes \api\** and never matches any request URL.
Replace it with a minimal local utility (src/utils/slasher.ts) that uses
path.posix throughout, guaranteeing forward slashes on all platforms.
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.
Description
Headers, redirects, and rewrites config rules are silently ignored on Windows. Any glob pattern without a leading slash — e.g.
api/**,**/*.json— is never matched, so configured rules have no effect.Root cause
glob-slasher (v1.0.1, 2014, unmaintained) depends on
glob-slash, which normalizes patterns using Node'spathmodule:On Windows,
path.normalizeconverts forward slashes to backslashes. The patternapi/**becomes\api\**, which never matches a URL like/api/data.json.Fix
Replace
glob-slasherwith a small local utility (src/utils/slasher.ts) that usespath.posixthroughout, guaranteeing forward slashes on all platforms.glob-slasherand its transitive dependencies (glob-slash,toxic,lodash.isobject,lodash._objecttypes) are removed frompackage.json.Proof of concept (verified on Windows)
Create a directory with the following files and run
npm install && npm start:package.json{ "name": "superstatic-windows-glob-poc", "private": true, "scripts": { "start": "superstatic . -c config.json" }, "dependencies": { "superstatic": "10.0.0" } }config.json{ "public": "public", "headers": [ { "source": "api/**", "headers": [ { "key": "X-Bug-Fixed", "value": "true" } ] } ] }public/api/data.json{ "message": "If the response includes 'X-Bug-Fixed: true', the glob pattern matched correctly.", "expected_header": "X-Bug-Fixed: true" }Then verify with:
X-Bug-Fixedheadersuperstatic@10.0.0(npm)true— fixedTo reproduce with the fix, change the dependency to
"superstatic": "https://github.com/Frank3K/superstatic.git#fix-windows-glob-matching"and re-runnpm install.Related PRs