fix: resolve vault-root-relative wiki links#183
Open
jakobvongehlen wants to merge 1 commit intosecure-77:mainfrom
Open
fix: resolve vault-root-relative wiki links#183jakobvongehlen wants to merge 1 commit intosecure-77:mainfrom
jakobvongehlen wants to merge 1 commit intosecure-77:mainfrom
Conversation
When niceLinks=true (default), [[category/name]] links were incorrectly
resolved relative to the current file's subdirectory instead of from
the vault root.
Before: [[references/arxiv-2507.21678]] from /projects/infosse
resolved to 'projects/references/arxiv-2507.21678' (wrong)
After: [[references/arxiv-2507.21678]] from /projects/infosse
resolves to 'references/arxiv-2507.21678' (correct)
The fix adds a check: if the link already contains a path separator,
treat it as vault-root-relative and use an empty base path. Bare
filenames (no '/') continue to resolve from the current file's
subdirectory, preserving existing behavior for same-folder links.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: vault-root-relative wiki links resolve from vault root, not current file directory
Problem
When a markdown file in a subdirectory (e.g.
projects/my-project/notes.md) links to another file using a vault-root-relative path like[[references/arxiv-2507.21678]], Perlite was incorrectly resolving the link relative to the current file's directory, producing an incorrect path likeprojects/my-project/references/arxiv-2507.21678instead ofreferences/arxiv-2507.21678.Root Cause
In
PerliteParsedown.php, thesafeLinkUri()method applies "current-file-relative" path stripping to all non-absolute links. This logic was designed for bare-filename links (e.g.[[other-note]]) but was incorrectly also running on vault-root-relative links.Solution
Detect whether the link target contains a path separator (
/). Only apply the current-file-relative resolution to bare filenames (no/). For vault-root-relative links (which contain/), reset the base path to''so resolution starts from the vault root.