Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 28 additions & 152 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"destroy": "^1.0.4",
"is-url": "^1.2.2",
"mime-types": "^3.0.2",
"minimatch": "^6.1.6",
"minimatch": "^11.0.10",
"morgan": "^1.8.2",
"on-finished": "^2.2.0",
"on-headers": "^1.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/utils/patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export function configMatcher(
const glob = config.glob ?? config.source;
const regex = config.regex;
if (glob) {
return minimatch(path, glob);
// Match HTTP URL paths with POSIX semantics regardless of host OS.
return minimatch(path, glob, { platform: "linux" });
}
if (regex) {
const pattern = RE2 ? new RE2(regex, "u") : new RegExp(regex, "u");
Expand Down
43 changes: 43 additions & 0 deletions test/unit/utils/patterns.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,49 @@ describe("patterns", () => {
patterns.configMatcher("/foo", { glob: "", source: "", regex: "" }),
).to.equal(false);
});

it("uses POSIX URL matching even when minimatch defaults to win32", () => {
const baseRequire = originalCreateRequire(__filename);
const patternsPath = baseRequire.resolve("../../../src/utils/patterns");
const minimatchPath = baseRequire.resolve("minimatch");
const prevPlatform = process.env.__MINIMATCH_TESTING_PLATFORM__;

process.env.__MINIMATCH_TESTING_PLATFORM__ = "win32";
delete require.cache[minimatchPath];
delete require.cache[patternsPath];

try {
const winPatterns = baseRequire(patternsPath) as PatternsModule;

// Leading "//" is collapsed like a URL path, not treated as a Windows UNC root.
expect(
winPatterns.configMatcher("//foo/bar", { glob: "/foo/bar" }),
).to.equal(true);
// Backslashes in a URL path are not treated as path separators.
expect(
winPatterns.configMatcher("/foo\\bar", { glob: "/foo/bar" }),
).to.equal(false);
// UNC host/share case-insensitivity and long UNC aliases do not apply to URLs.
expect(
winPatterns.configMatcher("//host/share/file", {
glob: "//HOST/SHARE/file",
}),
).to.equal(false);
expect(
winPatterns.configMatcher("//?/UNC/host/share/a", {
glob: "//host/share/a",
}),
).to.equal(false);
} finally {
if (prevPlatform === undefined) {
delete process.env.__MINIMATCH_TESTING_PLATFORM__;
} else {
process.env.__MINIMATCH_TESTING_PLATFORM__ = prevPlatform;
}
delete require.cache[minimatchPath];
delete require.cache[patternsPath];
}
});
});

describe("createRaw", () => {
Expand Down