chore: updated path utils
This commit is contained in:
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1857,7 +1857,7 @@
|
||||
},
|
||||
"node_modules/@quartz-community/utils": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "git+ssh://git@github.com/quartz-community/utils.git#cf1450b6f744755c16ca0d301db08c2ade6cfb67",
|
||||
"resolved": "git+ssh://git@github.com/quartz-community/utils.git#e17fc8d5f027eed1dfba1848ef1dd41633521558",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
@@ -120,6 +120,18 @@ describe("transforms", () => {
|
||||
["test/special chars?.md", "test/special-chars"],
|
||||
["test/special chars #3.md", "test/special-chars-3"],
|
||||
["cool/what about r&d?.md", "cool/what-about-r-and-d"],
|
||||
// Obsidian "Folder Notes" convention: folder/folder.md is the folder's landing page
|
||||
["characters/characters.md", "characters/index"],
|
||||
["fiction/books/books.md", "fiction/books/index"],
|
||||
["a/a/a.md", "a/a/index"],
|
||||
// Top-level single-segment: NOT rewritten (parentFolder storage, out of scope)
|
||||
["characters.md", "characters"],
|
||||
// Non-matching last two segments: no rewrite
|
||||
["characters/alice.md", "characters/alice"],
|
||||
["characters/sub/characters.md", "characters/sub/characters"],
|
||||
// Folder literally named "index" is unaffected by the rewrite
|
||||
["index/index.md", "index/index"],
|
||||
["docs/index/index.md", "docs/index/index"],
|
||||
],
|
||||
path.slugifyFilePath,
|
||||
path.isFilePath,
|
||||
@@ -127,6 +139,16 @@ describe("transforms", () => {
|
||||
)
|
||||
})
|
||||
|
||||
test("slugifyFilePath + simplifySlug end-to-end canonicalization", () => {
|
||||
// Both folder-note conventions must produce identical user-facing URLs.
|
||||
const indexStyle = path.simplifySlug(path.slugifyFilePath("characters/index.md" as any))
|
||||
const folderNameStyle = path.simplifySlug(
|
||||
path.slugifyFilePath("characters/characters.md" as any),
|
||||
)
|
||||
assert.strictEqual(indexStyle, folderNameStyle)
|
||||
assert.strictEqual(indexStyle, "characters/")
|
||||
})
|
||||
|
||||
test("transformInternalLink", () => {
|
||||
asserts(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user