소스 검색

Fix findDocument absolute path matching logic

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 <noreply@anthropic.com>
Tobi Lutke 5 달 전
부모
커밋
5dcf2417cf
1개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 11 2
      src/store.ts

+ 11 - 2
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}