-
Notifications
You must be signed in to change notification settings - Fork 118
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 regex for validating mirror remoteUrl #1029
Conversation
Motivation: The regex for validating mirror remoteUrl is wrong. `[.-\/]` is interpreted as `.` to `/`. However, it should be `[.\-\/]` which allows `.`, `-` and `/` characters. Modifications: - Fixed regex for validating mirror remoteUrl Result: - You can now correctly setup a mirror url when it contains `-` in its name.
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.
👍 👍 👍
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.
Thanks!
@@ -300,7 +300,7 @@ const MirrorForm = ({ projectName, defaultValue, onSubmit, isWaitingResponse }: | |||
type="text" | |||
defaultValue={defaultValue.remoteUrl} | |||
placeholder="my.git.com/org/myrepo.git" | |||
{...register('remoteUrl', { required: true, pattern: /^[\w.-]+(:[0-9]+)?\/[\w.-\/]+.git$/ })} | |||
{...register('remoteUrl', { required: true, pattern: /^[\w.-]+(:[0-9]+)?\/[\w.\-\/]+.git$/ })} |
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.
😅
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.
By the way, do we have to escape the first -
?
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.
We don't have to because -
is in the last position in []
. However, let me add it for clarification.
Motivation:
The regex for validating mirror remoteUrl is wrong.
[.-\/]
is interpreted as.
to/
. However, it should be[.\-\/]
which allows.
,-
and/
characters.Modifications:
Result:
-
in its name.