Skip to content

Commit

Permalink
 #577960: [SXA] fixed middleware redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
sc-ruslanmatkovskyi committed Apr 13, 2023
1 parent 5fac4fc commit 349467c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Our versioning strategy is as follows:

* `[sitecore-jss-nextjs]` Fix for Link component which throws error if field is undefined ([#1425](https://github.com/Sitecore/jss/pull/1425))
* `[templates/react]` Fix compilation error when developing react template in monorepo ([#1428](https://github.com/Sitecore/jss/pull/1428))
* `[sitecore-jss-nextjs]` Fix regex for middleware redirects ([#1431](https://github.com/Sitecore/jss/pull/1431))

## 21.1.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ export class RedirectsMiddleware extends MiddlewareBase {

return redirects.length
? redirects.find((redirect: RedirectInfo) => {
const pattern = `/^/${redirect.pattern.toLowerCase().replace(/^\/|\/$/g,'').replace(/^\^|\$$/g,'')}$/`;

return (
(regexParser(redirect.pattern.toLowerCase()).test(req.nextUrl.pathname.toLowerCase()) ||
regexParser(redirect.pattern.toLowerCase()).test(
(regexParser(pattern).test(req.nextUrl.pathname.toLowerCase()) ||
regexParser(pattern).test(
`/${req.nextUrl.locale}${req.nextUrl.pathname}`.toLowerCase()
)) &&
(redirect.locale
Expand Down

0 comments on commit 349467c

Please sign in to comment.