Skip to content

Commit

Permalink
fix: handler files with index as substring
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Jul 5, 2022
1 parent 4b23370 commit 5a4019c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/runtime/server/transformers/path-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function refineUrlPart (name: string): string {
if (SEMVER_REGEX.test(name)) {
return name
}

return (
name
/**
Expand All @@ -91,10 +92,10 @@ export function refineUrlPart (name: string): string {
/**
* Remove index keyword
*/
.replace(/^index/, '')
.replace(/^index(\.draft)?$/, '')
/**
* Remove draft keyword
*/
.replace(/\.draft/, '')
.replace(/\.draft$/, '')
)
}
14 changes: 14 additions & 0 deletions test/features/transformer-path-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ const testCases = {
_draft: false,
_partial: false,
_path: '/one/fileparamvaluehash'
},
'content:indexer.md': {
__description: 'non-index file with index substring',
title: 'Indexer',
_draft: false,
_partial: false,
_path: '/indexer'
},
'content:indexer.draft.md': {
__description: 'non-index file with index substring',
title: 'Indexer',
_draft: true,
_partial: false,
_path: '/indexer'
}
}

Expand Down

0 comments on commit 5a4019c

Please sign in to comment.