Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1298. Wikilink definitions links not working. #1311

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

MABruni
Copy link
Contributor

@MABruni MABruni commented Dec 10, 2023

This is a fix for #1298.

The issue was that link creation was being done literally, and some special characters can break URLs, for example:

  • Create placeholder note [[test:1]]
  • Click on the link to create the note and save.
  • Update wikilink definitions: This creates a link that is interpreted as linking to a note called 1 instead of test:1
  • The original note changes to a placeholder note because now it links to a note called "1" that doesn't exist.

The solution involves using encodeURIComponent() to properly encode special characters in the generated links. This ensures that links work with several unsafe special characters that were breaking links before (:, ?, ^, {, }, ~, %).

Copy link
Collaborator

@riccardoferretti riccardoferretti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks great, thanks @MABruni! Could you add a test for it?

@MABruni
Copy link
Contributor Author

MABruni commented Dec 12, 2023

Thank you, @riccardoferretti!

I have added two tests, one to check that encoding is handled correctly and the original filename is preserved and another one to check that links generated resolve correctly. Both of them test wikilinks containing the most common symbols that can break a URL. I also had to modify some previous tests to handle the encoded links.

I tried to be consistent with previous tests and I checked that all of them pass; but let me know if there is anything that I may have overlooked!

Copy link
Collaborator

@riccardoferretti riccardoferretti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good thx!

@riccardoferretti riccardoferretti merged commit 4d99883 into foambubble:master Dec 13, 2023
3 checks passed
@riccardoferretti
Copy link
Collaborator

@allcontributors add @MABruni for code

Copy link
Contributor

@riccardoferretti

I've put up a pull request to add @MABruni! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants