diff --git a/src/path.ts b/src/path.ts index be61805..f000a63 100644 --- a/src/path.ts +++ b/src/path.ts @@ -303,6 +303,7 @@ export function slugifyPath(s: string): string { .replace(/%/g, "-percent") .replace(/\?/g, "") .replace(/#/g, "") + .replace(/[<>:"|*]/g, "") .toLowerCase(), ) .join("/") diff --git a/test/path.test.ts b/test/path.test.ts index ddc0e69..94ee669 100644 --- a/test/path.test.ts +++ b/test/path.test.ts @@ -287,6 +287,24 @@ describe("slugifyPath", () => { it("lowercases for case-insensitive matching (Obsidian parity)", () => { expect(slugifyPath("Compendium/Species/Dryad/Apple")).toBe("compendium/species/dryad/apple"); }); + + it('removes filesystem-illegal characters (< > : " | *)', () => { + expect(slugifyPath("Alias with chars")).toBe("alias-with-illegal-chars"); + }); + + it("removes colons and pipes", () => { + expect(slugifyPath("Title: Subtitle | Part")).toBe("title-subtitle--part"); + }); + + it("removes asterisks and quotes", () => { + expect(slugifyPath('What is "AI"*')).toBe("what-is-ai"); + }); + + it("handles mixed illegal characters across path segments", () => { + expect(slugifyPath("Guides/X-Men: First Class/Notes ")).toBe( + "guides/x-men-first-class/notes-draft", + ); + }); }); describe("splitAnchor", () => {