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

linkValidaton encodes URL #1218

Closed
cruzanmo opened this issue Sep 19, 2016 · 2 comments
Closed

linkValidaton encodes URL #1218

cruzanmo opened this issue Sep 19, 2016 · 2 comments

Comments

@cruzanmo
Copy link
Contributor

cruzanmo commented Sep 19, 2016

Description

Not sure why linkValidation is encoding the URL?

return (urlSchemeRegex.test(value) ? '' : 'http://') + encodeURI(value);

Steps to reproduce

  1. add an anchor button with linkValidation: true
  2. select text and add a link that has encoded characters, e.g. http://site.com/?q=http%3A%2F%2Fsite2.com
  3. click checkmark to save link to text.

Expected behavior:
Text should have a link as entered: <a href="http://site.com/?q=http%3A%2F%2Fsite2.com">text</a>

Actual behavior:
Link is encoded: <a href="http://site.com/?q=http%253A%252F%252Fsite2.com">text</a>

Versions

  • medium-editor: 5.22.0
  • browser: all
  • OS: all
@j0k3r
Copy link
Contributor

j0k3r commented Sep 20, 2016

Might be related to #1025

It's mostly to handle url that contains spaces.
Maybe we should go with value.replace(/\s/g, '%20') to only replace spaces?

@cruzanmo
Copy link
Contributor Author

Looks like it used to be a regex like that: 5a9f383

If spaces are encoded, then everything should probably be encoded.

Hmm, the solution might be to check if the URL was already encoded, and then only encode if it was not already encoded.

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

No branches or pull requests

2 participants