mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-13 14:40:54 +08:00
GitHostSetup: Use git_url_parse2 to try to verify the url
This way if the url is invalid we will know before trying to clone, which happens much later during the process.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:git_url_parse2/git_url_parse2.dart';
|
||||
import 'package:function_types/function_types.dart';
|
||||
import 'package:gitjournal/apis/githost_factory.dart';
|
||||
|
||||
@ -184,22 +185,19 @@ class GitCloneUrlKnownProviderPageState
|
||||
}
|
||||
|
||||
// Returns null when valid
|
||||
String _isCloneUrlValid(String value) {
|
||||
value = value.trim();
|
||||
if (value.isEmpty) {
|
||||
String _isCloneUrlValid(String url) {
|
||||
url = url.trim();
|
||||
if (url.isEmpty) {
|
||||
return 'Please enter some text';
|
||||
}
|
||||
if (value.startsWith('https://') ||
|
||||
value.startsWith('http://') ||
|
||||
value.startsWith('git://') ||
|
||||
value.startsWith('ssh+git://') ||
|
||||
value.startsWith('git+ssh://')) {
|
||||
return 'Only SSH urls are currently accepted';
|
||||
|
||||
var result = gitUrlParse(url);
|
||||
if (result == null) {
|
||||
return 'Invalid Input';
|
||||
}
|
||||
|
||||
RegExp regExp = RegExp(r".*@.*");
|
||||
if (!regExp.hasMatch(value)) {
|
||||
return "Invalid Input";
|
||||
if (result.protocol != 'ssh') {
|
||||
return 'Only SSH urls are currently accepted';
|
||||
}
|
||||
|
||||
return null;
|
||||
|
23
pubspec.lock
23
pubspec.lock
@ -224,6 +224,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
freezed_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: freezed_annotation
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.0"
|
||||
fuchsia_remote_debug_protocol:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@ -243,6 +250,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.11"
|
||||
git_url_parse2:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: git_url_parse2
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -306,6 +320,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.1+1"
|
||||
json_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_annotation
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
json_rpc_2:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -753,5 +774,5 @@ packages:
|
||||
source: hosted
|
||||
version: "0.0.5"
|
||||
sdks:
|
||||
dart: ">=2.5.0 <3.0.0"
|
||||
dart: ">=2.7.0 <3.0.0"
|
||||
flutter: ">=1.12.13+hotfix.4 <2.0.0"
|
||||
|
@ -35,6 +35,7 @@ dependencies:
|
||||
yaml_serializer: ^0.0.5
|
||||
connectivity: ^0.4.6+1
|
||||
flutter_emoji: ">= 2.0.0"
|
||||
git_url_parse2: ^0.0.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_launcher_icons: "^0.7.2"
|
||||
|
Reference in New Issue
Block a user