Skip to content

Commit f6de393

Browse files
committed
Skip invalid URLs in inline-media
1 parent 0adaefe commit f6de393

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tasks/inline-media.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,16 @@ const getFullTaskList = (options) => {
400400
// Deduplicate, filter out media already on the Ghost site,
401401
// and filter by asset domain if specified
402402
mediaUrls = [...new Set(mediaUrls)].filter((url) => {
403+
// Skip malformed URLs (e.g. concatenated URLs like "https://site.comhttps://other.com/...")
404+
try {
405+
const parsed = new URL(url);
406+
if (parsed.hostname.includes('http') || (url.match(/https?:\/\//g) || []).length > 1) {
407+
return false;
408+
}
409+
} catch (e) {
410+
return false;
411+
}
412+
403413
if (url.startsWith(ctx.siteUrl)) {
404414
return false;
405415
}

0 commit comments

Comments
 (0)