// ── Path helpers ── // Pure functions only: no 'obsidian' imports, so this stays unit-testable in plain node. /** * Remap a stored vault path after a rename. * * Obsidian's `vault.on('rename')` fires for folders as well as files, so a * stored path can be affected either because it *is* the renamed item or * because it lives inside a renamed folder. * * The nested check requires a `/` boundary, so renaming `notes/foo` leaves * `notes/foobar.md` untouched. * * @returns the updated path, or `null` when `path` is unaffected. */ export function remapRenamedPath(path: string, oldPath: string, newPath: string): string | null { if (!path || !oldPath) return null; if (path === oldPath) return newPath; if (path.startsWith(oldPath + '/')) return newPath + path.slice(oldPath.length); return null; }