diff --git a/quartz/util/path.test.ts b/quartz/util/path.test.ts index 18edc940..16e0311d 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 6cedffdb..95acf119 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(/\/$/, "") }