fix: sluggify pound (closes #681)

This commit is contained in:
Jacky Zhao 2024-01-13 09:22:27 -08:00
parent 0a8c38dc21
commit 6babb788ed
2 changed files with 5 additions and 1 deletions

View File

@ -105,6 +105,8 @@ describe("transforms", () => {
["index.md", "index"], ["index.md", "index"],
["test.mp4", "test.mp4"], ["test.mp4", "test.mp4"],
["note with spaces.md", "note-with-spaces"], ["note with spaces.md", "note-with-spaces"],
["test/special chars?.md", "test/special-chars-q"],
["test/special chars #3.md", "test/special-chars-3"],
], ],
path.slugifyFilePath, path.slugifyFilePath,
path.isFilePath, path.isFilePath,

View File

@ -50,7 +50,9 @@ export function getFullSlug(window: Window): FullSlug {
function sluggify(s: string): string { function sluggify(s: string): string {
return s return s
.split("/") .split("/")
.map((segment) => segment.replace(/\s/g, "-").replace(/%/g, "-percent").replace(/\?/g, "-q")) // slugify all segments .map((segment) =>
segment.replace(/\s/g, "-").replace(/%/g, "-percent").replace(/\?/g, "-q").replace(/#/g, ""),
) // slugify all segments
.join("/") // always use / as sep .join("/") // always use / as sep
.replace(/\/$/, "") .replace(/\/$/, "")
} }