From f3232561c51b4188d7cbe81f3020f0c738ea7ee8 Mon Sep 17 00:00:00 2001 From: Jonas Thelemann Date: Sat, 31 Dec 2022 00:17:11 +0100 Subject: [PATCH] fix(prerender): check link's pathname only for extensions If a link contains parts following the pathname, e.g. a query or hash, the file extension would not be found. Links that appear to have no file extension would then NOT be excluded from crawling. Those included links led the crawler to request, e.g. static, files on which `vue-bundle-renderer` would produce a memory overflow. --- src/prerender.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/prerender.ts b/src/prerender.ts index 9daad9555d..00f1d0529d 100644 --- a/src/prerender.ts +++ b/src/prerender.ts @@ -276,6 +276,7 @@ function extractLinks( const EXT_REGEX = /\.[\da-z]+$/; -function getExtension(path: string): string { - return (path.match(EXT_REGEX) || [])[0] || ""; +function getExtension(link: string): string { + const pathname = parseURL(link).pathname; + return (pathname.match(EXT_REGEX) || [])[0] || ""; }