Skip to content

Commit

Permalink
fix additional bug not visible until Stephane made his fix: ignoreQue…
Browse files Browse the repository at this point in the history
…ryString resulted in a crash if the URL contained a query string
  • Loading branch information
boutell committed Feb 23, 2024
1 parent f17b2f1 commit ba5cc84
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ba5cc84

Please sign in to comment.