Skip to content

Commit

Permalink
Add additional test for named regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jan 27, 2020
1 parent 2c26320 commit 30533e9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/integration/custom-routes/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ module.exports = {
destination: '/another/:0/:test/:1',
permanent: false,
},
{
source: '/docs/:first(integrations|now-cli)/v2:second(.*)',
destination: '/:first*/:second*',
permanent: false,
},
]
},

Expand Down
22 changes: 22 additions & 0 deletions test/integration/custom-routes/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ const runTests = (isDev = false) => {
expect(pathname).toBe('/another/first/second/hello/world')
})

it('should handle named regex parameters with multi-match successfully', async () => {
const res = await fetchViaHTTP(
appPort,
'/docs/integrations/v2-some/thing',
undefined,
{
redirect: 'manual',
}
)
const { pathname } = url.parse(res.headers.get('location') || '')
expect(res.status).toBe(307)
expect(pathname).toBe('/integrations/-some/thing')
})

if (!isDev) {
it('should output routes-manifest successfully', async () => {
const manifest = await fs.readJSON(
Expand Down Expand Up @@ -411,6 +425,14 @@ const runTests = (isDev = false) => {
source: '/unnamed-params/nested/(.*?)/:test/(.*)',
statusCode: 307,
},
{
destination: '/:first*/:second*',
regex: normalizeRegEx(
'^\\/docs(?:\\/(integrations|now-cli))\\/v2(.*)$'
),
source: '/docs/:first(integrations|now-cli)/v2:second(.*)',
statusCode: 307,
},
],
headers: [
{
Expand Down

0 comments on commit 30533e9

Please sign in to comment.