From bf5b267360acd7e53dbad1a24b6a4243037cde58 Mon Sep 17 00:00:00 2001 From: Derwish Date: Thu, 15 Apr 2021 05:25:54 +0300 Subject: [PATCH] internal links fix --- manifest.json | 2 +- src/files-handler.ts | 3 +++ src/links-handler.ts | 7 +++++-- versions.json | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 144513f..006be35 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "consistent-attachments-and-links", "name": "Consistent attachments and links", - "version": "1.0.6", + "version": "1.0.7", "minAppVersion": "0.9.12", "description": "This plugin ensures the consistency of attachments and links", "author": "Dmitry Savosh", diff --git a/src/files-handler.ts b/src/files-handler.ts index b9b33b6..6695ae5 100644 --- a/src/files-handler.ts +++ b/src/files-handler.ts @@ -165,6 +165,9 @@ export class FilesHandler { for (let l of links) { let link = this.lh.splitLinkToPathAndSection(l.link).link; + if (link.startsWith("#")) //internal section link + continue; + if (link.endsWith(".md")) continue; diff --git a/src/links-handler.ts b/src/links-handler.ts index 9d5bcff..29d15e9 100644 --- a/src/links-handler.ts +++ b/src/links-handler.ts @@ -314,7 +314,7 @@ export class LinksHandler { //!!! this can return undefined if note was just updated let links = this.app.metadataCache.getCache(note.path)?.links; if (links) { - for (let link of links) { + for (let link of links) { if (this.checkIsCorrectWikiLink(link.original)) continue; @@ -644,7 +644,7 @@ export class LinksHandler { if (notePath == filePath) continue; - let links = await this.getLinksFromNote(notePath); + let links = await this.getLinksFromNote(notePath); for (let link of links) { let li = this.splitLinkToPathAndSection(link.link); let linkFullPath = this.getFullPathForLink(li.link, notePath); @@ -790,6 +790,9 @@ export class LinksHandler { let isMarkdownLink = this.checkIsCorrectMarkdownLink(link.original); let isWikiLink = this.checkIsCorrectWikiLink(link.original); if (isMarkdownLink || isWikiLink) { + if (link.link.startsWith("#")) //internal section link + continue; + let file = this.getFileByLink(link.link, notePath); if (file) continue; diff --git a/versions.json b/versions.json index 0688e86..97bc968 100644 --- a/versions.json +++ b/versions.json @@ -1,4 +1,5 @@ { + "1.0.7": "0.9.12", "1.0.6": "0.9.12", "1.0.5": "0.9.12", "1.0.4": "0.9.12",