Skip to content

Commit

Permalink
#hotfix: fixed return data of redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
sc-ruslanmatkovskyi committed Jun 17, 2022
1 parent e46bdb3 commit ca3ab65
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/sitecore-jss-nextjs/src/edge/redirects-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ export class RedirectsMiddleware {
* @returns Promise<RedirectInfo | undefined>
* @private
*/
private async getExistsRedirect(req: NextRequest): Promise<RedirectInfo | undefined> {
private async getExistsRedirect(req: NextRequest): Promise<RedirectInfo | void> {
const redirects = await this.redirectsService.fetchRedirects();

return redirects.find(
(redirect: RedirectInfo) =>
regexParser(redirect.pattern).test(req.nextUrl.pathname) ||
regexParser(redirect.pattern).test(`/${req.nextUrl.locale}${req.nextUrl.pathname}`)
);
if (Array.isArray(redirects)) {
return redirects.find(
(redirect: RedirectInfo) =>
regexParser(redirect.pattern).test(req.nextUrl.pathname) ||
regexParser(redirect.pattern).test(`/${req.nextUrl.locale}${req.nextUrl.pathname}`)
);
}
}
}

0 comments on commit ca3ab65

Please sign in to comment.