From 6babb788edbdeaf532d406d6daa4d046e5223c7b Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Sat, 13 Jan 2024 09:22:27 -0800 Subject: [PATCH] fix: sluggify pound (closes #681) --- quartz/util/path.test.ts | 2 ++ quartz/util/path.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/quartz/util/path.test.ts b/quartz/util/path.test.ts index 18edc94..16e0311 100644 --- a/quartz/util/path.test.ts +++ b/quartz/util/path.test.ts @@ -105,6 +105,8 @@ describe("transforms", () => { ["index.md", "index"], ["test.mp4", "test.mp4"], ["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.isFilePath, diff --git a/quartz/util/path.ts b/quartz/util/path.ts index 6cedffd..95acf11 100644 --- a/quartz/util/path.ts +++ b/quartz/util/path.ts @@ -50,7 +50,9 @@ export function getFullSlug(window: Window): FullSlug { function sluggify(s: string): string { return s .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 .replace(/\/$/, "") }