editor.js
editor.js copied to clipboard
[Bug] Pasted link cannot include spaces
I kept getting a front-end validation error when checking a link my client provided. Here's a sample one:
http://www.example.com/my-document v12.3.xslx
This is a valid URL when URL encoded to:
http://www.example.com/my-document%20v12.3.xslx
The average person who uses these code editors won't know about spaces in URLs, and most other tools tolerate the spaces. My search turned up this as the culprit:
https://github.com/codex-team/editor.js/blob/9cdda110dac04c70cf137ef324085e5326c448ec/src/components/inline-tools/inline-tool-link.ts#L326-L337
Maybe improving it to prefix search for http:
, https:
, or /
would be better?
/^(http?s:|\/)/.test(str)
Steps to reproduce:
- https://editorjs.io/
- Select text in the editor
- Insert an inline link to
http://www.example.com/my-document v12.3.xslx
- Note the URL validation error.
Expected behavior:
- It should insert the link, optionally URL encoding it.
Screenshots:
Device, Browser, OS: any
Editor.js version: current