improve url handling and support uri schemes and fragments #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 inwww.hello.world
appended relatively) It didn't allowhttp://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 successfullyauto
| Clicking an autocompleted link should be workhttp://wwwuzzzuppp.com
| Links that didn't work before should workrelative-link
| This should show the Invalid URL error messagewww.hello.world
| Pressing enter should show the Invalid URL error messageSupport for 2 URI Schemes and URL Fragments
closes #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 apply 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 linktel:5555555555
| Pressing enter should add the tel link#hello
| Pressing enter should add the url fragment to the linkThe fragments should work really well with this plugin. https://github.com/Aleksst95/header-with-anchor