codex-team / codex-team/editor.js
[Bug] Pasted link cannot include spaces
- Dominant language
- TypeScript
- Stars
- 31.9k
- Forks
- 2.2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
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:
1. https://editorjs.io/
2. Select text in the editor
3. Insert an inline link to `http://www.example.com/my-document v12.3.xslx`
4. 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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.