Handle uppercase absolute request URL schemes
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
814f075ddc
commit
9b8d67e932
2 files changed
+9
-1
No files matched your search
@@ -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
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user