Skip to content

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

Description

@serhalp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions