diff --git a/.changeset/lucky-tables-jam.md b/.changeset/lucky-tables-jam.md new file mode 100644 index 000000000000..2b334b36f876 --- /dev/null +++ b/.changeset/lucky-tables-jam.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: prevent crawling empty urls (``) diff --git a/packages/kit/src/core/postbuild/crawl.js b/packages/kit/src/core/postbuild/crawl.js index 255d6e443e65..fd1bd4c9e683 100644 --- a/packages/kit/src/core/postbuild/crawl.js +++ b/packages/kit/src/core/postbuild/crawl.js @@ -165,7 +165,7 @@ export function crawl(html) { } else if (name === 'rel') { rel = value; } else if (name === 'src') { - hrefs.push(value); + if (value) hrefs.push(value); } else if (name === 'srcset') { const candidates = []; let insideURL = true; @@ -183,7 +183,7 @@ export function crawl(html) { candidates.push(value); for (const candidate of candidates) { const src = candidate.split(WHITESPACE)[0]; - hrefs.push(src); + if (src) hrefs.push(src); } } } else { diff --git a/packages/kit/src/core/postbuild/fixtures/basic-src/input.html b/packages/kit/src/core/postbuild/fixtures/basic-src/input.html index 82c55c8f2780..52d4ee72b077 100644 --- a/packages/kit/src/core/postbuild/fixtures/basic-src/input.html +++ b/packages/kit/src/core/postbuild/fixtures/basic-src/input.html @@ -3,5 +3,6 @@
+