[remix] Support optional static path segments (#9607)

Fixes https://github.com/orgs/vercel/discussions/1707.
This commit is contained in:
Nathan Rajlich
2023-03-06 16:50:37 -08:00
committed by GitHub
parent 2e8423e24e
commit 57e8ec13cf
7 changed files with 235 additions and 9 deletions

View File

@@ -104,6 +104,14 @@ describe('getPathFromRoute()', () => {
parentId: 'root',
file: 'routes/($lang)/$pid.tsx',
},
'routes/admin.(lol)': {
path: 'admin/lol?',
index: undefined,
caseSensitive: undefined,
id: 'routes/admin.(lol)',
parentId: 'root',
file: 'routes/admin.(lol).tsx',
},
};
it.each([
@@ -156,6 +164,10 @@ describe('getPathFromRoute()', () => {
id: 'routes/($lang)/$pid',
expected: { path: '(:lang)/:pid', rePath: '/:lang?/:pid' },
},
{
id: 'routes/admin.(lol)',
expected: { path: 'admin/(lol)', rePath: '/admin/(lol)?' },
},
])('should return `$expected` for "$id" route', ({ id, expected }) => {
const route = routes[id];
expect(getPathFromRoute(route, routes)).toMatchObject(expected);