mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 01:02:14 +08:00
CloneUrlValidation: Our regexp is broken
With AWS Code commit we get URLs of the form - ssh://APKAZLZA77YWDCWYRAC5@git-codecommit.eu-west-1.amazonaws.com/v1/repos/blah All our assumptions about how the URL should be are now invalid. It's best to just check for the presence of an '@'
This commit is contained in:
@ -49,22 +49,7 @@ class GitCloneUrlPageState extends State<GitCloneUrlPage> {
|
|||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
hintText: 'git@github.com:GitJournal/GitJournal.git',
|
hintText: 'git@github.com:GitJournal/GitJournal.git',
|
||||||
),
|
),
|
||||||
validator: (String value) {
|
validator: _isCloneUrlValid,
|
||||||
value = value.trim();
|
|
||||||
if (value.isEmpty) {
|
|
||||||
return 'Please enter some text';
|
|
||||||
}
|
|
||||||
if (value.startsWith('https://') || value.startsWith('http://')) {
|
|
||||||
return 'Only SSH urls are currently accepted';
|
|
||||||
}
|
|
||||||
|
|
||||||
RegExp regExp = RegExp(r"[a-zA-Z0-9.]+@[a-zA-Z0-9.-]+:.+");
|
|
||||||
if (!regExp.hasMatch(value)) {
|
|
||||||
return "Invalid Input";
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
focusNode: inputFormFocus,
|
focusNode: inputFormFocus,
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
onFieldSubmitted: (String _) => formSubmitted(),
|
onFieldSubmitted: (String _) => formSubmitted(),
|
||||||
@ -147,22 +132,7 @@ class GitCloneUrlKnownProviderPageState
|
|||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
hintText: 'git@github.com:GitJournal/GitJournal.git',
|
hintText: 'git@github.com:GitJournal/GitJournal.git',
|
||||||
),
|
),
|
||||||
validator: (String value) {
|
validator: _isCloneUrlValid,
|
||||||
value = value.trim();
|
|
||||||
if (value.isEmpty) {
|
|
||||||
return 'Please enter some text';
|
|
||||||
}
|
|
||||||
if (value.startsWith('https://') || value.startsWith('http://')) {
|
|
||||||
return 'Only SSH urls are currently accepted';
|
|
||||||
}
|
|
||||||
|
|
||||||
RegExp regExp = RegExp(r"[a-zA-Z0-9.]+@[a-zA-Z0-9.]+:.+");
|
|
||||||
if (!regExp.hasMatch(value)) {
|
|
||||||
return "Invalid Input";
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
focusNode: inputFormFocus,
|
focusNode: inputFormFocus,
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
onFieldSubmitted: (String _) => formSubmitted(),
|
onFieldSubmitted: (String _) => formSubmitted(),
|
||||||
@ -208,3 +178,21 @@ class GitCloneUrlKnownProviderPageState
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns null when valid
|
||||||
|
String _isCloneUrlValid(String value) {
|
||||||
|
value = value.trim();
|
||||||
|
if (value.isEmpty) {
|
||||||
|
return 'Please enter some text';
|
||||||
|
}
|
||||||
|
if (value.startsWith('https://') || value.startsWith('http://')) {
|
||||||
|
return 'Only SSH urls are currently accepted';
|
||||||
|
}
|
||||||
|
|
||||||
|
RegExp regExp = RegExp(r".*@.*");
|
||||||
|
if (!regExp.hasMatch(value)) {
|
||||||
|
return "Invalid Input foo";
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user