Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve url handling and support uri schemes and fragments
I'm breaking up my large pull request into smaller ones to make it easier to test the changes. These are only the changes in how URLs are handled. First, there was a bug in the regex used in Utils.isUrl(). It allowed - www.hello.world (without a protocol, resulting in www.hello.world appended relatively) It didn't allow - http://wwwuzzzuppp.com Since relative links are likely being autocompleted through an API, it makes sense that the URL regex should be expecting absolute URLs. It's been updated to do that. It also requires the protocol, since absolute URLs should specify a protocol. TESTING URL REGEX: In the editor add these links. -[ ] https://editorjs.io/ | Link should be added successfully -[ ] auto | Clicking an autocompleted link should be work -[ ] http://wwwuzzzuppp.com | Links that didn't work before should work -[ ] relative-link | This should show the Invalid URL error message -[ ] www.hello.world | Pressing enter should show the Invalid URL error message Support for 2 URI Schemes and URL Fragments closes editor-js#6 | mailto link support In the same method as the URL regex - Utils.isUrl(), we also check if the url starts with 'mailto:' 'tel:' or '#' and then applies an appropriate regex to test the remaining URL. The email regex uses control characters so I had to disable no-control-regex in .eslintrc TESTING URI SCHEMES In the editor add these links -[ ] mailto:[email protected] | Pressing enter should add the mailto link -[ ] tel:5555555555 | Pressing enter should add the tel link -[ ] #hello | Pressing enter should add the url fragment to the link The fragments should work really well with this plugin. https://github.com/Aleksst95/header-with-anchor
- Loading branch information