Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

fix: derive Windows relative paths by segments

nash_suc537fe1674e6
diff --git a/src/lib/path-utils.test.ts b/src/lib/path-utils.test.ts
index 0b85145e..3317fe13 100644
--- a/src/lib/path-utils.test.ts
+++ b/src/lib/path-utils.test.ts
@@ -127,6 +127,10 @@ describe("getRelativePath", () => {
expect(getRelativePath("//server/SHARE/sub/file.md", "//SERVER/share")).toBe("sub/file.md")
})
+ it("does not derive the relative offset from case-folded character length", () => {
+ expect(getRelativePath("c:/i\u0307/sub/file.md", "C:/\u0130")).toBe("sub/file.md")
+ })
+
it("keeps Unix paths case-sensitive", () => {
expect(getRelativePath("/Project/wiki/note.md", "/project")).toBe("/Project/wiki/note.md")
})
diff --git a/src/lib/path-utils.ts b/src/lib/path-utils.ts
index c1e5c7ae..1343ed7f 100644
--- a/src/lib/path-utils.ts
+++ b/src/lib/path-utils.ts
@@ -50,7 +50,10 @@ export function getRelativePath(fullPath: string, basePath: string): string {
const fullKey = caseFoldPath(normalFull)
const baseKey = caseFoldPath(normalBase)
if (fullKey.startsWith(baseKey + "/")) {
- return normalFull.slice(normalBase.length + 1)
+ // Slice by path segments rather than the original string length. Unicode
+ // case folding can change UTF-16 length, so an offset derived from the
+ // differently-cased base can split the returned relative path incorrectly.
+ return normalFull.split("/").slice(normalBase.split("/").length).join("/")
}
return normalFull
}