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`).
This commit is contained in:
Raphael Hubain 2026-04-27 20:46:51 +02:00 committed by GitHub
parent 70d82e700b
commit c1987a46f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}