Skip to content

Commit

Permalink
 #530504: added check for locale of site and fixed query string (#1460)
Browse files Browse the repository at this point in the history
  • Loading branch information
sc-ruslanmatkovskyi authored May 2, 2023
1 parent c4de04e commit 6302177
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Our versioning strategy is as follows:
* `[sitecore-jss-angular]` Fix memory leak in image and link components ([#1435](https://github.com/Sitecore/jss/pull/1435))
* `[templates/nextjs-multisite]` Fix skipped site info fetch ([#1434](https://github.com/Sitecore/jss/pull/1434))
* `[angular]` Fix app build errors. Webpack version is locked at 5.78 due to https://github.com/webpack/webpack/issues/16981 ([#1448](https://github.com/Sitecore/jss/pull/1448))
* `[sitecore-jss-nextjs]` Fix middleware redirect when the target use regexp with querystring ([#1449](https://github.com/Sitecore/jss/pull/1449))
* `[sitecore-jss-nextjs]` Fix middleware redirect when the target use regexp with querystring ([#1449](https://github.com/Sitecore/jss/pull/1449)) ([#1460](https://github.com/Sitecore/jss/pull/1460))

## 21.1.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ describe('RedirectsMiddleware', () => {
const req = createRequest({
nextUrl: {
pathname: '/not-found',
search: 'abc=def',
search: '?abc=def',
href: 'http://localhost:3000/found?abc=def',
locale: 'en',
clone() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class RedirectsMiddleware extends MiddlewareBase {
): Promise<RedirectInfo | undefined> {
const redirects = await this.redirectsService.fetchRedirects(siteName);
const tragetURL = req.nextUrl.pathname;
const targetQS = `?${req.nextUrl.search || ''}`;
const targetQS = req.nextUrl.search || '';

return redirects.length
? redirects.find((redirect: RedirectInfo) => {
Expand All @@ -175,7 +175,8 @@ export class RedirectsMiddleware extends MiddlewareBase {
return (
(regexParser(pattern).test(tragetURL) ||
regexParser(pattern).test(`${tragetURL}${targetQS}`) ||
regexParser(pattern).test(`/${req.nextUrl.locale}${tragetURL}`.toLowerCase())) &&
regexParser(pattern).test(`/${req.nextUrl.locale}${tragetURL}`) ||
regexParser(pattern).test(`/${req.nextUrl.locale}${tragetURL}${targetQS}`)) &&
(redirect.locale
? redirect.locale.toLowerCase() === req.nextUrl.locale.toLowerCase()
: true)
Expand Down

0 comments on commit 6302177

Please sign in to comment.