Skip to content

Commit

Permalink
fix: dont strip trailing index from links unless it is the full segment
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Dec 19, 2024
1 parent 15f877f commit 5d03224
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/starlight-links-validator/libs/remark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function normalizeFilePath(base: string, srcDir: URL, filePath?: string) {
const path = nodePath
.relative(nodePath.join(fileURLToPath(srcDir), 'content/docs'), filePath)
.replace(/\.\w+$/, '')
.replace(/index$/, '')
.replace(/(^|[/\\])index$/, '$1')
.replace(/[/\\]?$/, '/')
.split(/[/\\]/)
.map((segment) => slug(segment))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: A page that ends with index
---

Content
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ title: Index
- [An MDX nested page](/guides/example)
- [An MDX nested page](/guides/example/)

- [A page that ends with index](/a-page-that-ends-with-index)

# More links

- [Link to hash in this page](#some-links)
Expand Down

0 comments on commit 5d03224

Please sign in to comment.