mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-06 14:22:47 +02:00
feat: enhance Obsidian plugin with folder management features, including inclusion/exclusion settings and a status modal for real-time updates
This commit is contained in:
parent
2251e464c7
commit
28d3c628f1
11 changed files with 267 additions and 154 deletions
|
|
@ -64,3 +64,31 @@ export function parseExcludePatterns(raw: string): string[] {
|
|||
.map((line) => line.trim())
|
||||
.filter((line) => line.length > 0 && !line.startsWith("#"));
|
||||
}
|
||||
|
||||
/** Normalize a folder path: strip leading/trailing slashes; "" or "/" means vault root. */
|
||||
export function normalizeFolder(folder: string): string {
|
||||
return folder.replace(/^\/+|\/+$/g, "");
|
||||
}
|
||||
|
||||
/** True if `path` lives inside `folder` (or `folder` is the vault root). */
|
||||
export function isInFolder(path: string, folder: string): boolean {
|
||||
const f = normalizeFolder(folder);
|
||||
if (f === "") return true;
|
||||
return path === f || path.startsWith(`${f}/`);
|
||||
}
|
||||
|
||||
/** Exclude wins over include. Empty includeFolders means "include everything". */
|
||||
export function isFolderFiltered(
|
||||
path: string,
|
||||
includeFolders: string[],
|
||||
excludeFolders: string[],
|
||||
): boolean {
|
||||
for (const f of excludeFolders) {
|
||||
if (isInFolder(path, f)) return true;
|
||||
}
|
||||
if (includeFolders.length === 0) return false;
|
||||
for (const f of includeFolders) {
|
||||
if (isInFolder(path, f)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue