From c1987a46f1c9228d84f8502b90796ab0eb21650f Mon Sep 17 00:00:00 2001 From: Raphael Hubain <4274733+rhubain@users.noreply.github.com> Date: Mon, 27 Apr 2026 20:46:51 +0200 Subject: [PATCH] Fix: '/' in excluded folders now matches every file (#5) When the user adds the vault root ('/') to the auto-generation exclusion list, no file was actually excluded. `normalizePath('/')` returns `'/'`, but file paths in Obsidian never start with a slash (e.g. `note.md`, `sub/note.md`), so the existing checks `path.startsWith('/' + '/')` and `path === '/'` could never match. Treat `normEx === '/'` as "matches every file in the vault". This is consistent with how the same file already interprets the vault root in `getFilesInFolder` and `clearUIDsInFolder` (commands.ts:134, :274), where `targetPath === '/'` expands to every markdown file. Applied to both exclusion checks: the per-file auto-generation handler (`handleAutoGenerateUid`) and the bulk scan (`handleAddMissingUidsInScope`). --- src/commands.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index c1786e9..5a8bf05 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -313,7 +313,9 @@ export async function handleAutoGenerateUid(plugin: UIDGenerator, file: TFile | // Check exclusions if (plugin.settings.autoGenerationExclusions.some(ex => { const normEx = normalizePath(ex.trim()); - return normEx && (normalizedPath.startsWith(normEx + '/') || normalizedPath === normEx); + // '/' means the vault root — matches every file, consistent with + // how the vault root is treated in getFilesInFolder / clearUIDsInFolder. + return normEx && (normEx === '/' || normalizedPath.startsWith(normEx + '/') || normalizedPath === normEx); })) { return; // Excluded } @@ -367,7 +369,9 @@ export async function handleAddMissingUidsInScope(plugin: UIDGenerator): Promise // 1. Check exclusions if (plugin.settings.autoGenerationExclusions.some(ex => { const normEx = normalizePath(ex.trim()); - return normEx && (normalizedPath.startsWith(normEx + '/') || normalizedPath === normEx); + // '/' means the vault root — matches every file, consistent with + // how the vault root is treated in getFilesInFolder / clearUIDsInFolder. + return normEx && (normEx === '/' || normalizedPath.startsWith(normEx + '/') || normalizedPath === normEx); })) { isInScope = false; // Excluded }