Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not correctly handle user middleware that redirects to path with canonical locale casing when app enables skipMiddlewareUrlNormalize and path contains locale slug with non-canonical casing #2474

Open
serhalp opened this issue Jun 13, 2024 · 0 comments
Labels
Next.js e2e test failure Errors identified through the Next.js repo e2e tests Next.js

Comments

@serhalp
Copy link
Contributor

serhalp commented Jun 13, 2024

I'm not quite sure exactly what the scope of this is, but the failing tests here have a fixture site that enables skipMiddlewareUrlNormalize and a user middleware that redirects any other casing of /en/* to /en/* (and so on), but when /EN is fetched it redirects to /en/en instead of /en:

  ● skip-trailing-slash-redirect › should be able to redirect locale casing $1

    expect(received).toBe(expected) // Object.is equality

    Expected: "/en"
    Received: "/en/en"

      155 |       const res = await next.fetch(`/${locale}`, { redirect: 'manual' })
      156 |       expect(res.status).toBe(307)
    > 157 |       expect(new URL(res.headers.get('location'), 'http://n').pathname).toBe(
          |                                                                         ^
      158 |         `/${locale.toLowerCase()}`
      159 |       )
      160 |     }

      at toBe (e2e/skip-trailing-slash-redirect/index.test.ts:157:73)

  ● skip-trailing-slash-redirect › should be able to redirect locale casing $1

    expect(received).toBe(expected) // Object.is equality

    Expected: "/ja-jp"
    Received: "/ja-jp/ja-jp"

      155 |       const res = await next.fetch(`/${locale}`, { redirect: 'manual' })
      156 |       expect(res.status).toBe(307)
    > 157 |       expect(new URL(res.headers.get('location'), 'http://n').pathname).toBe(
          |                                                                         ^
      158 |         `/${locale.toLowerCase()}`
      159 |       )
      160 |     }

      at toBe (e2e/skip-trailing-slash-redirect/index.test.ts:157:73)

It looks like we previously claimed to have fixed this in FRA-332, but it must have regressed at some point.

Data

The following is parsed automatically by the Next.js repo e2e test report generator.

test: test/e2e/skip-trailing-slash-redirect/index.test.ts
reason: does not correctly handle user middleware that redirects to path with canonical locale casing when app enables skipMiddlewareUrlNormalize and path contains locale slug with non-canonical casing

@serhalp serhalp added type: bug code to address defects in shipped code Next.js e2e test failure Errors identified through the Next.js repo e2e tests labels Jun 13, 2024
@serhalp serhalp added the Next.js label Jun 14, 2024 — with Linear
@serhalp serhalp removed the type: bug code to address defects in shipped code label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Next.js e2e test failure Errors identified through the Next.js repo e2e tests Next.js
Projects
None yet
Development

No branches or pull requests

1 participant