-
Notifications
You must be signed in to change notification settings - Fork 67
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: regular expression for validating registry URL #2192
Conversation
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
---|---|---|---|
🔴 | Statements | 3.15% (+0.01% 🔼) |
101/3209 |
🔴 | Branches | 3.34% (+0.02% 🔼) |
67/2007 |
🔴 | Functions | 1.56% (+0.01% 🔼) |
17/1092 |
🔴 | Lines | 3.21% (+0.01% 🔼) |
101/3150 |
Test suite run success
20 tests passing in 4 suites.
Report generated by 🧪jest coverage report action from 5b3fc87
@@ -265,6 +262,14 @@ const ContainerRegistryEditorModal: React.FC< | |||
) { | |||
return Promise.reject(t('registry.DescURLStartString')); | |||
} | |||
const pattern = new RegExp( |
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.
Is there any reason not to use new URL(url)
to validate URL?
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.
Oh sorry, you mentioned in the PR description. I'll check
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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 agree with @yomybaby. Besides, the performance of new URL is better than RegEx.
This pull request is automatically being deployed by Amplify Hosting (learn more). |
@@ -265,6 +262,14 @@ const ContainerRegistryEditorModal: React.FC< | |||
) { | |||
return Promise.reject(t('registry.DescURLStartString')); | |||
} | |||
const pattern = new RegExp( |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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
return Promise.reject(t('registry.DescURLStartString')); | ||
if (value) { | ||
if ( | ||
!value.startsWith('http://') && |
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.
You can use protocol
property of new URL()
.
This PR resolves #2190
Main Idea
There are some chances that user could use customized hostname with port number, but antd input form validation on URL type doesn't work properly on these cases. URL validation need to accept the addresses like "bai-repo:####".
Changes
Checklist: (if applicable)