obsidian-url-into-selection
obsidian-url-into-selection copied to clipboard
decode uri: for better readability
decode url like Chinese or other special characters for better readability
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>)
.
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.
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.
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.