From 0d2bc9024f7692e38a392d9045fb92037f0dd592 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Mon, 5 Jun 2023 04:16:48 +0200 Subject: [PATCH] Stripping query for URL matching. --- src/dissectLink.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dissectLink.js b/src/dissectLink.js index 061d057..3ea065c 100644 --- a/src/dissectLink.js +++ b/src/dissectLink.js @@ -118,7 +118,9 @@ module.exports = function dissectLink(url) { return acc; } - const match = host.pattern.match(url.replace(/(https?:\/\/)|(\/)+/g, '$1$2')); // remove double slashes + // const match = host.pattern.match(url.replace(/(https?:\/\/)|(\/)+/g, '$1$2')); // remove double slashes + const { origin, pathname } = new URL(url); + const match = host.pattern.match(`${origin}${pathname}`); // remove double slashes if (match) { return Object.assign(match, {