mirror of
https://github.com/netajam/obsidian_note_uid_generator.git
synced 2026-07-22 05:45:32 +00:00
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:
parent
70d82e700b
commit
c1987a46f1
1 changed files with 6 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue