Skip to content

Commit bf14411

Browse files
authored
fix: handler files with index as substring (#1334)
1 parent 98064e8 commit bf14411

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/runtime/server/transformers/path-meta.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export function refineUrlPart (name: string): string {
8282
if (SEMVER_REGEX.test(name)) {
8383
return name
8484
}
85+
8586
return (
8687
name
8788
/**
@@ -91,10 +92,10 @@ export function refineUrlPart (name: string): string {
9192
/**
9293
* Remove index keyword
9394
*/
94-
.replace(/^index/, '')
95+
.replace(/^index(\.draft)?$/, '')
9596
/**
9697
* Remove draft keyword
9798
*/
98-
.replace(/\.draft/, '')
99+
.replace(/\.draft$/, '')
99100
)
100101
}

test/features/transformer-path-meta.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ const testCases = {
5353
_draft: false,
5454
_partial: false,
5555
_path: '/one/fileparamvaluehash'
56+
},
57+
'content:indexer.md': {
58+
__description: 'non-index file with index substring',
59+
title: 'Indexer',
60+
_draft: false,
61+
_partial: false,
62+
_path: '/indexer'
63+
},
64+
'content:indexer.draft.md': {
65+
__description: 'non-index file with index substring',
66+
title: 'Indexer',
67+
_draft: true,
68+
_partial: false,
69+
_path: '/indexer'
5670
}
5771
}
5872

0 commit comments

Comments
 (0)