From 66a5ebfbb70f0469a06c1755adf3bd6067c46f5b Mon Sep 17 00:00:00 2001 From: sec77 <31564517+secure-77@users.noreply.github.com> Date: Thu, 1 Oct 2026 12:20:47 +0200 Subject: [PATCH] fixed links in graph and canvas --- perlite/.js/perlite.js | 4 ++-- perlite/.src/PerliteCanvas.php | 9 ++------- perlite/.src/PerliteParsedown.php | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/perlite/.js/perlite.js b/perlite/.js/perlite.js index bc1ed2e3..5f7cf30c 100644 --- a/perlite/.js/perlite.js +++ b/perlite/.js/perlite.js @@ -72,7 +72,7 @@ function unslugURL(targetPath) { function slugURL(targetPath) { encodedURI = decodeURIComponent(targetPath) - encodedURI = encodedURI.replaceAll('~', '%80') + encodedURI = encodedURI.replaceAll('~', '%2580') encodedURI = encodedURI.replaceAll('-', '~') encodedURI = encodedURI.replaceAll(' ', '-') @@ -1207,7 +1207,7 @@ function renderGraph(modal, path = "", filter_emptyNodes = false, show_tags = tr search(node.title); } else { - var glink = uriPath + node.title; + var glink = uriPath + slugURL(encodeURIComponent('/' + node.title)); window.open(glink, "_self"); } }); diff --git a/perlite/.src/PerliteCanvas.php b/perlite/.src/PerliteCanvas.php index beedf373..9edbe753 100644 --- a/perlite/.src/PerliteCanvas.php +++ b/perlite/.src/PerliteCanvas.php @@ -1,7 +1,7 @@ uriPath . $slug; + return $this->uriPath . PerliteParsedown::slugPath(ltrim($path, '/')); } // direct url of a vault file, served by the webserver diff --git a/perlite/.src/PerliteParsedown.php b/perlite/.src/PerliteParsedown.php index dc3ffa7a..0c5405e1 100644 --- a/perlite/.src/PerliteParsedown.php +++ b/perlite/.src/PerliteParsedown.php @@ -1,7 +1,7 @@ "%2580" (decodes to "%80"), "-" -> "~", " " -> "-" + public static function slugPath(string $path): string + { + $path = str_replace('~', '%2580', $path); + $path = str_replace('-', '~', $path); + $path = str_replace(' ', '-', $path); + + return $path; + } + # # YAML Front Matter / Obsidian Properties # See: https://help.obsidian.md/Editing+and+formatting/Properties @@ -1595,9 +1606,7 @@ protected function inlineInternalLink($Excerpt) if ($openNewTab == false) { $urlPath = str_replace('&', '&', $urlPath); $urlPath = str_replace('%23', '#', $urlPath); - $urlPath = str_replace('~', '%80', $urlPath); - $urlPath = str_replace('-', '~', $urlPath); - $urlPath = str_replace(' ', '-', $urlPath); + $urlPath = self::slugPath($urlPath); } return array(