Skip to content

Commit 1455aee

Browse files
authored
fix(sort_routes.ts): optional route parameters sorting (#1077)
fixes #1016
1 parent 82a4073 commit 1455aee

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/qwik-city/buildtime/routing/sort-routes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ export function routeSortCompare(a: BuildRoute, b: BuildRoute) {
99

1010
// /x < /x/y, but /[...x]/y < /[...x]
1111
if (!sa) {
12-
return a.id.includes('[...') ? 1 : -1;
12+
return a.pathname.includes('[...') ? 1 : -1;
1313
}
1414
if (!sb) {
15-
return b.id.includes('[...') ? -1 : 1;
15+
return b.pathname.includes('[...') ? -1 : 1;
1616
}
1717

1818
const maxParts = Math.max(sa.length, sb.length);

packages/qwik-city/buildtime/routing/sort-routes.unit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { test } from 'uvu';
22
import { equal } from 'uvu/assert';
33
import type { BuildRoute } from '../types';
4+
import { createFileId } from '../utils/fs';
45
import { parseRoutePathname } from './parse-pathname';
56
import { routeSortCompare } from './sort-routes';
67

@@ -45,7 +46,7 @@ test('routeSortCompare', () => {
4546
function route(r: TestRoute) {
4647
const pathname = r.pathname || '/';
4748
const route: BuildRoute = {
48-
id: pathname,
49+
id: createFileId('', pathname),
4950
filePath: pathname,
5051
pathname,
5152
ext: '.tsx',

0 commit comments

Comments
 (0)