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

decode uri: for better readability #27

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Benature
Copy link

decode url like Chinese or other special characters for better readability

@NomarCub
Copy link

I applied the diff to my local vault and it works, thanks!
However it has a problem. If the decoded URL has a space in it, the link becomes invalid in Markdown and gets resolved incorrectly by Obsidian. In that case, surrounding the link with angled brackets solves it, like so: [link text](<https://example.org/some made up URL with spaces>).

@Benature
Copy link
Author

Indeed, sorry that I overlook this condition. I add a replace so that space will keep in %20, I think this can solve the problem.

@NomarCub
Copy link

There are whitespace characters other than the normal space that break this, such as the full-width space ( ) used in Japanese. It would probably be a more universal and safe solution to detect if the string has any whitespace, and if it does, wrap it in brackets.

@Benature
Copy link
Author

Oh! I miss reading the <> in your first comment🤦‍♂️

I use /\s/g to detect space, and check whether the URL is wrapped in brackets already (/^<.*?>$/g), as processUrl() may add brackets.

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