File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
packages/kit/src/core/sync
write_types/test/app-types Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @sveltejs/kit ' : patch
3
+ ---
4
+
5
+ fix: add trailing slash pathname when generating typed routes
Original file line number Diff line number Diff line change @@ -66,10 +66,21 @@ function generate_app_types(manifest_data) {
66
66
dynamic_routes . push ( route_type ) ;
67
67
68
68
const pathname = remove_group_segments ( route . id ) ;
69
- pathnames . add ( `\`${ replace_required_params ( replace_optional_params ( pathname ) ) } \` & {}` ) ;
69
+ const replaced_pathname = replace_required_params ( replace_optional_params ( pathname ) ) ;
70
+ pathnames . add ( `\`${ replaced_pathname } \` & {}` ) ;
71
+
72
+ if ( pathname !== '/' ) {
73
+ // Support trailing slash
74
+ pathnames . add ( `\`${ replaced_pathname + '/' } \` & {}` ) ;
75
+ }
70
76
} else {
71
77
const pathname = remove_group_segments ( route . id ) ;
72
78
pathnames . add ( s ( pathname ) ) ;
79
+
80
+ if ( pathname !== '/' ) {
81
+ // Support trailing slash
82
+ pathnames . add ( s ( pathname + '/' ) ) ;
83
+ }
73
84
}
74
85
75
86
/** @type {Map<string, boolean> } */
Original file line number Diff line number Diff line change @@ -26,9 +26,12 @@ declare let pathname: Pathname;
26
26
pathname = '/nope' ;
27
27
pathname = '/foo' ;
28
28
pathname = '/foo/1/2' ;
29
+ pathname = '/foo/' ;
30
+ pathname = '/foo/1/2/' ;
29
31
30
32
// Test layout groups
31
33
pathname = '/path-a' ;
34
+ pathname = '/path-a/' ;
32
35
// @ts -expect-error layout group names are NOT part of the pathname type
33
36
pathname = '/(group)/path-a' ;
34
37
You can’t perform that action at this time.
0 commit comments