From ba5cc8403903aa4fb0c7e271ee169579f7613ba8 Mon Sep 17 00:00:00 2001 From: Thomas Boutell Date: Fri, 23 Feb 2024 14:32:25 -0500 Subject: [PATCH] fix additional bug not visible until Stephane made his fix: ignoreQueryString resulted in a crash if the URL contained a query string --- i18n/en.json | 4 ++-- index.js | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index 0194a71..726e0d6 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -7,8 +7,8 @@ "urlType": "Link Type", "urlTypeInternal": "Internal Page", "urlTypeExternal": "External URL", - "ignoreQuery": "Ignore query string when matching.", - "forwardQuery": "Forward query string.", + "ignoreQuery": "Ignore query string when matching", + "forwardQuery": "Forward query string", "newPage": "Page Title", "external": "URL", "statusCode": "Redirect Type", diff --git a/index.js b/index.js index 8665166..db68541 100644 --- a/index.js +++ b/index.js @@ -197,10 +197,16 @@ module.exports = { } const foundTarget = results.find(({ redirectSlug }) => redirectSlug === slug) || - results.find(({ - redirectSlug, - ignoreQueryString - }) => redirectSlug === pathOnly && ignoreQueryString); + results.find(({ + redirectSlug, + ignoreQueryString + }) => redirectSlug === pathOnly && ignoreQueryString); + + if (!foundTarget) { + // Query will produce a match if the path matches, but we need + // to implement ignoreQueryString: false properly + return await emitAndRedirectOrNext(); + } const shouldForwardQueryString = foundTarget && foundTarget.forwardQueryString;