Skip to content

Commit

Permalink
[sitecore-jss-nextjs]: Removed a method that addressed Netlify issue…
Browse files Browse the repository at this point in the history
…s. Added a simpler solution for non-regex patterns to fix Netlify-related problems. Improved redirect performance.
  • Loading branch information
Ruslan Matkovskyi committed Jan 15, 2025
1 parent 48f55f3 commit a6fdb73
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ describe('RedirectsMiddleware', () => {
request: {
nextUrl: {
pathname: '/not-found',
search: 'abc=def',
search: '',
href: 'http://localhost:3000/not-found',
locale: 'en',
origin: 'http://localhost:3000',
Expand Down Expand Up @@ -1361,7 +1361,7 @@ describe('RedirectsMiddleware', () => {
expect(finalRes.status).to.equal(res.status);
});

it('should return 301 redirect when queryString is ordered by alphabetic(Netlify feature)', async () => {
it('should return 301 redirect when pattern has special symbols "?"', async () => {
const cloneUrl = () => Object.assign({}, req.nextUrl);
const url = {
clone: cloneUrl,
Expand Down Expand Up @@ -1389,7 +1389,7 @@ describe('RedirectsMiddleware', () => {

const { finalRes, fetchRedirects, siteResolver } = await runTestWithRedirect(
{
pattern: '/not-found?w=1&a=1',
pattern: '/[/]?not-found?a=1&w=1/',
target: '/found',
redirectType: REDIRECT_TYPE_301,
isQueryStringPreserved: true,
Expand All @@ -1412,7 +1412,7 @@ describe('RedirectsMiddleware', () => {
expect(finalRes.status).to.equal(res.status);
});

it('should return 301 redirect when pattern has special symbols "?"', async () => {
it('should return 301 redirect when pattern has another order of query string', async () => {
const cloneUrl = () => Object.assign({}, req.nextUrl);
const url = {
clone: cloneUrl,
Expand Down Expand Up @@ -1440,7 +1440,7 @@ describe('RedirectsMiddleware', () => {

const { finalRes, fetchRedirects, siteResolver } = await runTestWithRedirect(
{
pattern: '/[/]?not-found?a=1&w=1/',
pattern: '/not-found?w=1&a=1/',
target: '/found',
redirectType: REDIRECT_TYPE_301,
isQueryStringPreserved: true,
Expand Down
Loading

0 comments on commit a6fdb73

Please sign in to comment.