Handle uppercase absolute request URL schemes

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 02:43:55 +00:00
1 parent 814f075ddc
commit 9b8d67e932
2 files changed
+9 -1

No files matched your search

+8
View File
@@ -840,6 +840,14 @@ describe("resolveStaticAssetPath", () => {
});
});
it("supports uppercase absolute-form request target schemes", () => {
const result = resolveStaticAssetPath("HTTP://127.0.0.1/assets/main.js?x=1", distRoot);
expect(result).toEqual({
kind: "file",
filePath: path.join(distRoot, "assets", "main.js"),
});
});
it("rejects malformed absolute-form request targets", () => {
const result = resolveStaticAssetPath("http://%zz", distRoot);
expect(result).toEqual({
+1 -1
View File
@@ -526,7 +526,7 @@ export function resolveStaticAssetPath(
return "/";
}
if (requestUrl.startsWith("http://") || requestUrl.startsWith("https://")) {
if (/^https?:\/\//i.test(requestUrl)) {
try {
return new URL(requestUrl).pathname;
} catch {