-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
URL: Conform to URL Living Standard definition of valid URL #19871
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and couldn't see any regressions with the Nav Block. Simple and effective.
@getdave @WunderBart Would one or the other of you be able to approve the pull request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, thanks! 🚢
These are now considered valid by `isURL` and are not necessary to evaluate separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this 👍
d77f1b1
to
b2a3609
Compare
Upstream core patch: https://core.trac.wordpress.org/ticket/49360 The branch has been rebased to resolve conflicts, to add references to the above ticket (and a note about when the code can be removed from Gutenberg), and an additional check to make sure that the polyfill handling does not occur if the script is already registered (anticipating that this would be handled by core in the future). |
Changes on this PR: #19871 broke the native `is-url` version since it won't throw if the given string is not a url.
The polyfill chosen here will not be workable. An alternative is proposed in #20225. |
* Fix mobile version of is-url. Changes on this PR: #19871 broke the native `is-url` version since it won't throw if the given string is not a url. * Mobile unit tests to is-url + better REGEXP * Fix lint issues * Remove not-needed comment * Adding inline comments to explain `.match()` decision over `.test()`. * Sharing test suit with web.
Previously: #19816
Related: #9067
Cherry-picks e2c0f74 from #19823 (would require core back-port)
Unblocks: #19775
This pull request seeks to revise the implementation of
@wordpress/url
isURL
to accept more of what should be considered as valid URLs based on the URL Living Standard definition of a valid URL string.This includes a number of newly-acceptable URLs:
mailto
stringsftp:
,ssh:
,git:
, etc)The original implementation was introduced in #9067, and based on the discussion in that pull request, it seems it was largely intended as a refactoring to replace a simple (naive) regular expression, and wasn't explicitly concerned with dealing with HTTP URLs. In fact, the changes with this pull request should further improve upon the intended changes in #9067, where a link will automatically be applied to e.g.
mailto:[email protected]
if the text is highlighted in a paragraph.Testing Instructions:
Ensure unit tests pass:
Verify there are no regressions in the intended handling of
mailto:
andtel:
links in the Navigation Block link editor experience (#17846), nor in the behavior of URL paragraph text auto-linking (#9067).