From 5dcf2417cf1ccc5efdef76f1a51471c8c5242f91 Mon Sep 17 00:00:00 2001 From: Tobi Lutke Date: Sat, 13 Dec 2025 12:32:25 -0500 Subject: [PATCH] Fix findDocument absolute path matching logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function was incorrectly concatenating collection path with filepath even when filepath was already absolute, resulting in paths like '/exact/path//exact/path/mydoc.md'. Fixed to: - Check if filepath starts with collection path and extract relative part - Otherwise treat filepath as relative to collection This fixes 1 test, bringing us to 93 passing, 9 failing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/store.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/store.ts b/src/store.ts index 1eda6f8..d880903 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1947,8 +1947,17 @@ export function findDocument(db: Database, filename: string, options: { includeB if (!doc && !filepath.startsWith('qmd://')) { const collections = collectionsListCollections(); for (const coll of collections) { - const absPath = `${coll.path}/${filepath}`; - const relativePath = absPath.startsWith(coll.path + '/') ? absPath.slice(coll.path.length + 1) : null; + let relativePath: string | null = null; + + // If filepath is absolute and starts with collection path, extract relative part + if (filepath.startsWith(coll.path + '/')) { + relativePath = filepath.slice(coll.path.length + 1); + } + // Otherwise treat filepath as relative to collection + else if (!filepath.startsWith('/')) { + relativePath = filepath; + } + if (relativePath) { doc = db.prepare(` SELECT ${selectCols}