Skip to content

Commit

Permalink
[fix] consider protocol-relative URLs as external (#2062)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored Aug 1, 2021
1 parent e55bc44 commit 5911b1c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-lemons-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] consider protocol-relative URLs as external
2 changes: 1 addition & 1 deletion packages/kit/src/core/adapt/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export async function prerender({ cwd, out, log, config, build_data, fallback, a
if (!href) continue;

const resolved = resolve(path, href);
if (resolved[0] !== '/') continue;
if (!resolved.startsWith('/') || resolved.startsWith('//')) continue;

const parsed = new URL(resolved, 'http://localhost');

Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/server/page/load_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export async function load_node({
`http://${page.host}/${asset.file}`,
/** @type {RequestInit} */ (opts)
);
} else if (resolved.startsWith(options.paths.base || '/')) {
} else if (resolved.startsWith(options.paths.base || '/') && !resolved.startsWith('//')) {
const relative = resolved.replace(options.paths.base, '');

const headers = /** @type {import('types/helper').Headers} */ ({ ...opts.headers });
Expand Down

0 comments on commit 5911b1c

Please sign in to comment.