-
Notifications
You must be signed in to change notification settings - Fork 5
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
allow domain names in urls not starting with www #50
Conversation
src/pages/txt-generator.jsx
Outdated
/(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/ | ||
/(https?:\/\/(?:\.|(?!))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:\.|(?!))[a-zA-Z0-9]+\.[^\s]{2,}|\.[a-zA-Z0-9]+\.[^\s]{2,})/ |
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 think that you may need to remove the \.
that appeared after the www
portions. Currently, a URL like http://.example.org/mrf.json
will pass validation, but http://example.org/mrf.json
will fail. Additionally, the expression should enforce a full string match with ^
at the start and $
at the end. Otherwise, a typo like htps://example-hospital.com
could slip through.
I know you mentioned that you couldn't get the valid-url
package to do what you wanted, but I think trying to build up a huge regex like this is going to be hard to test. What about it wasn't working well?
Thanks Mint. The node valid-url module’s methods only check if a string is a valid uri, not a url, despite the name unless I’m missing something. https://www.npmjs.com/package/valid-url
Ed
From: Mint Thompson ***@***.***>
Sent: Tuesday, November 5, 2024 10:51 AM
To: CMSgov/hpt-tool ***@***.***>
Cc: Ed Overly ***@***.***>; Author ***@***.***>
Subject: [EXT] Re: [CMSgov/hpt-tool] allow domain names in urls not starting with www (PR #50)
@ mint-thompson requested changes on this pull request. In src/pages/txt-generator. jsx: > - /(https?: \/\/(?: www\. |(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\. [^\s]{2,}|www\. [a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\. [^\s]{2,}|https?: \/\/(?: www\. |(?!www))[a-zA-Z0-9]+\. [^\s]{2,}|www\. [a-zA-Z0-9]+\. [^\s]{2,})/
@mint-thompson requested changes on this pull request.
________________________________
In src/pages/txt-generator.jsx<https://urldefense.us/v2/url?u=https-3A__github.com_CMSgov_hpt-2Dtool_pull_50-23discussion-5Fr1829569965&d=DwMFaQ&c=Al8V6E3U0yBSSEuVtdZbGtsvjPA49U3WmtZAsdW0D_Q&r=SG2-2Bd5eLEKCVXNvxoIfPJDRAoAknTeKg0p_39QlPw&m=83rp96LF9-XXC-MMGgLIhkPmXuDMzqdXg4xZAWdST1uT5QjkoyYTij2UuhIIAZz5&s=m2LEZ7aTWORd515TI7lZH59NnLRY7dG6FvKl6tYcYRU&e=>:
- /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/
+ /(https?:\/\/(?:\.|(?!))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:\.|(?!))[a-zA-Z0-9]+\.[^\s]{2,}|\.[a-zA-Z0-9]+\.[^\s]{2,})/
I think that you may need to remove the \. that appeared after the www portions. Currently, a URL like http://.example.org/mrf.json<https://urldefense.us/v2/url?u=http-3A__.example.org_mrf.json&d=DwQFaQ&c=Al8V6E3U0yBSSEuVtdZbGtsvjPA49U3WmtZAsdW0D_Q&r=SG2-2Bd5eLEKCVXNvxoIfPJDRAoAknTeKg0p_39QlPw&m=83rp96LF9-XXC-MMGgLIhkPmXuDMzqdXg4xZAWdST1uT5QjkoyYTij2UuhIIAZz5&s=m2sALDy6uL8qTNBn1nI_32oYv8xB-e__vzV3A7G261A&e=> will pass validation, but http://example.org/mrf.json<https://urldefense.us/v2/url?u=http-3A__example.org_mrf.json&d=DwQFaQ&c=Al8V6E3U0yBSSEuVtdZbGtsvjPA49U3WmtZAsdW0D_Q&r=SG2-2Bd5eLEKCVXNvxoIfPJDRAoAknTeKg0p_39QlPw&m=83rp96LF9-XXC-MMGgLIhkPmXuDMzqdXg4xZAWdST1uT5QjkoyYTij2UuhIIAZz5&s=5BSQaOwG2jVtXeYqVIMzPW08kV3kMj7oc4BtKHHWYdc&e=> will fail. Additionally, the expression should enforce a full string match with ^ at the start and $ at the end. Otherwise, a typo like htps://example-hospital.com could slip through.
I know you mentioned that you couldn't get the valid-url package to do what you wanted, but I think trying to build up a huge regex like this is going to be hard to test. What about it wasn't working well?
—
Reply to this email directly, view it on GitHub<https://urldefense.us/v2/url?u=https-3A__github.com_CMSgov_hpt-2Dtool_pull_50-23pullrequestreview-2D2415988356&d=DwMFaQ&c=Al8V6E3U0yBSSEuVtdZbGtsvjPA49U3WmtZAsdW0D_Q&r=SG2-2Bd5eLEKCVXNvxoIfPJDRAoAknTeKg0p_39QlPw&m=83rp96LF9-XXC-MMGgLIhkPmXuDMzqdXg4xZAWdST1uT5QjkoyYTij2UuhIIAZz5&s=a1g48Fo9nzugsL_5TmxtGDNkCp1XVTtUoCdNNiFxLGI&e=>, or unsubscribe<https://urldefense.us/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ABANKU3RPS5T3LFA3ZV674DZ7DSMNAVCNFSM6AAAAABRFUSR2OVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDIMJVHE4DQMZVGY&d=DwMFaQ&c=Al8V6E3U0yBSSEuVtdZbGtsvjPA49U3WmtZAsdW0D_Q&r=SG2-2Bd5eLEKCVXNvxoIfPJDRAoAknTeKg0p_39QlPw&m=83rp96LF9-XXC-MMGgLIhkPmXuDMzqdXg4xZAWdST1uT5QjkoyYTij2UuhIIAZz5&s=oQ_PpgIymVtHHKfZ8jPog_pOvq4VhbhdnyiHdIDAZts&e=>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Edited the url regex |
One line description of your change (less than 72 characters)
Problem
Explain the context and why you're making that change. What is the problem
you're trying to solve? In some cases there is not a problem and this can be
thought of being the motivation for your change.
Solution
Describe the modifications you've done.
Result
What will change as a result of your pull request? Note that sometimes this
section is unnecessary because it is self-explanatory based on the solution.
Some important notes regarding the summary line:
Test Plan
(Write your test plan here. If you changed any code, please provide us with
clear instructions on how you verified your changes work.)