fix: URL-decode link_path of markdown-style links#1
Open
sajalverma17 wants to merge 3 commits intothat0n3guy:mainfrom
Open
fix: URL-decode link_path of markdown-style links#1sajalverma17 wants to merge 3 commits intothat0n3guy:mainfrom
sajalverma17 wants to merge 3 commits intothat0n3guy:mainfrom
Conversation
Markdown-style links with spaces have their paths URL-encoded (e.g., Note With Spaces.md becomes [Note With Spaces](Note%20With%20Spaces.md)). The fix uses unquote() to decode paths before matching them with provided target note name, returning correct backlinks and outgoing-links for notes with spaces in their names.
…so extracted from note content
Author
|
Hello @that0n3guy I wanted to follow up on this PR and confirm whether you agree with the bug diagnosis and proposed fix. I believe this fix is minimal and addresses the root cause without introducing breaking changes. If you have any concerns about the approach or would like me to provide additional context (tests, documentation, etc.), I'm happy to make those changes. Looking forward to your feedback. |
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.
Bug
get_backlinks_tool,get_outgoing_links_tool, andfind_broken_links_toolare broken. There might be other tools depending on this part of links management that might also be broken.Root cause
Markdown-style links have their link paths URL-encoded. For example, a Markdown-style link of
Note With Spaces.mdbecomes[Note With Spaces](Note%20With%20Spaces.md)in the containing note.links_management.pysearches for markdown-style links using theMARKDOWN_LINK_PATTERNregex pattern. When it finds matches, it takes thelink_pathpart of the link, and tries to equate it with the target note name provided in tool's query input. Thelink_pathcontains%20and does not match with the note name provided in the input.Fix
The fix uses unquote() to decode link paths, before matching them with provided target note name, returning correct backlinks and outgoing-links for notes with spaces in their names.
The fix is applied to
extract_links_from_content()function, as well asget_backlinkstool.Tests
The test suite looks like it is outdated. Nevertheless, I have added a unit test to
test_link_management.pyto verify the fix viaextract_links_from_content()function.