From 7aa8f3789ac0af819a16a6f510959059ceb07ed9 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 31 Jul 2023 22:07:33 +0200 Subject: [PATCH] Fix Exclusion not working as intended. --- manifest.json | 2 +- package.json | 2 +- src/types/MarkdownTextRenderer.ts | 5 ++++- src/types/Utilities.ts | 7 +------ versions.json | 3 ++- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest.json b/manifest.json index d02ad40..18f25ac 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-folder-index", "name": "Folder Index", - "version": "1.0.20", + "version": "1.0.21", "minAppVersion": "1.1.16", "description": "This Plugin will automatically generate a TOC for the current Folder.", "author": "turulix", diff --git a/package.json b/package.json index 5d741f6..ca96906 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-sample-plugin", - "version": "1.0.20", + "version": "1.0.21", "description": "This is a sample plugin for Obsidian (https://obsidian.md)", "main": "main.js", "scripts": { diff --git a/src/types/MarkdownTextRenderer.ts b/src/types/MarkdownTextRenderer.ts index 3d69615..45829c9 100644 --- a/src/types/MarkdownTextRenderer.ts +++ b/src/types/MarkdownTextRenderer.ts @@ -1,6 +1,6 @@ import {App, HeadingCache, TAbstractFile, TFile, TFolder} from "obsidian"; import FolderIndexPlugin from "../main"; -import {isIndexFile} from "./Utilities"; +import {isExcludedPath, isIndexFile} from "./Utilities"; type FileTree = (TFile | TFolder)[] type HeaderWrapper = { @@ -24,6 +24,9 @@ export class MarkdownTextRenderer { let markdownText = "" for (const file of fileTree) { + if(isExcludedPath(file.path)){ + continue + } if (file instanceof TFolder && this.plugin.settings.recursiveIndexFiles) { // Create a deep copy of the children array let children = file.children; diff --git a/src/types/Utilities.ts b/src/types/Utilities.ts index bcbe00b..f52ed90 100644 --- a/src/types/Utilities.ts +++ b/src/types/Utilities.ts @@ -19,15 +19,10 @@ export function isIndexFile(path: string) { } export function isExcludedPath(path: string) { - const pathParts = path.split(/\//) for (const excludedFolder of FolderIndexPlugin.PLUGIN.settings.excludeFolders) { if (excludedFolder == "") continue - let folder = pathParts.slice(0, pathParts.length - 1).join("/") - if (!folder.endsWith("/")) - folder += "/" - - if (RegExp(`^${excludedFolder}/?$`).test(folder)) + if (RegExp(`^${excludedFolder}$`).test(path)) return true; } return false diff --git a/versions.json b/versions.json index 7dacb65..9873609 100644 --- a/versions.json +++ b/versions.json @@ -11,5 +11,6 @@ "1.0.17": "1.1.16", "1.0.18": "1.1.16", "1.0.19": "1.1.16", - "1.0.20": "1.1.16" + "1.0.20": "1.1.16", + "1.0.21": "1.1.16" } \ No newline at end of file