-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix: Autolink plugin URL recognition failures #5275
Fix: Autolink plugin URL recognition failures #5275
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hi @disalechinmay! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
@disalechinmay could you do the CLA, otherwise LGTM |
This looks great, could you update the AutoLink tests to reflect your changes and I'll merge it. |
@ivailop7 - I've updated the tests 🧪 |
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.
LGTM
The complexity of this regexp seems problematic. Just open the playground and start typing to see what I mean. My browser starts dying when the input is around 30 characters long and freezes at 40. |
This reverts commit 0f7c78b.
It was, in fact, problematic. Reverted it - thanks for the catch. |
@acywatson , @thorn0 , the performance issue wasn't caused by this PR. See here for more info. |
I'm pretty certain that it was. If you go back literally one commit and check the preview deployment, the issue isn't there. There may be multiple issues here, but I think this PR is part of the problem at least. |
This PR fixes #5254
The above issue was happening because period (
.
) was being considered as a separator sequence (PUNCTUATION_OR_SPACE
inpackages/lexical-react/src/LexicalAutoLinkPlugin.ts
) which is wrong.Additionally, this PR introduces an enhancement to the existing regular expression used for URL validation. The existing regex for URL validation was effective but limited in scope, failing to recognize several common URL formats. With the growing need for more comprehensive URL validation in modern web applications, it became imperative to update our regex to handle a broader range of URLs, including those with user credentials and special domains like 'localhost', as well as IP addresses. To ensure the robustness of the updated regex, a series of tests were conducted with various URL formats. The test results show a comparison between the old variant of the regex and the new enhanced variant. The new variant successfully matches a wider range of URLs, making it a more versatile choice for URL validation.
http://example.com
https://www.example.com
www.example.com
example.com
http://localhost:8000
ftp://example.com
http://example.com/path/to/resource?query=string#fragment
example
http://192.168.1.1
https://example.com:3000/path
http://example.com:8080/path
https://subdomain.example.com
http://127.0.0.1
http://example.com/path/to/page.html
https://example.com?param=value
http://example.co.uk
https://255.255.255.255
https://example.com#anchor
http://example.com/path/to/page.html?query=string#fragment
http://[::1]
(IPv6 address)https://username:[email protected]
ftp://192.168.0.1/resource
http://example
(no TLD)http://.com
(no domain name)https://example.com:invalidport
(invalid port)http:///path/without/domain
(missing domain)http://-example.com
(invalid domain start)http://example-.com
(invalid domain end)http://example..com
(double dot in domain)http://ex..ample.com
(double dot in domain)http://abcdefghij.com
(long domain name)