mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-13 22:53:45 +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/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:git_url_parse2/git_url_parse2.dart';
|
||||||
import 'package:function_types/function_types.dart';
|
import 'package:function_types/function_types.dart';
|
||||||
import 'package:gitjournal/apis/githost_factory.dart';
|
import 'package:gitjournal/apis/githost_factory.dart';
|
||||||
|
|
||||||
@ -184,22 +185,19 @@ class GitCloneUrlKnownProviderPageState
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns null when valid
|
// Returns null when valid
|
||||||
String _isCloneUrlValid(String value) {
|
String _isCloneUrlValid(String url) {
|
||||||
value = value.trim();
|
url = url.trim();
|
||||||
if (value.isEmpty) {
|
if (url.isEmpty) {
|
||||||
return 'Please enter some text';
|
return 'Please enter some text';
|
||||||
}
|
}
|
||||||
if (value.startsWith('https://') ||
|
|
||||||
value.startsWith('http://') ||
|
var result = gitUrlParse(url);
|
||||||
value.startsWith('git://') ||
|
if (result == null) {
|
||||||
value.startsWith('ssh+git://') ||
|
return 'Invalid Input';
|
||||||
value.startsWith('git+ssh://')) {
|
|
||||||
return 'Only SSH urls are currently accepted';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegExp regExp = RegExp(r".*@.*");
|
if (result.protocol != 'ssh') {
|
||||||
if (!regExp.hasMatch(value)) {
|
return 'Only SSH urls are currently accepted';
|
||||||
return "Invalid Input";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
23
pubspec.lock
23
pubspec.lock
@ -224,6 +224,13 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
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:
|
fuchsia_remote_debug_protocol:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -243,6 +250,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.0.11"
|
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:
|
glob:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -306,6 +320,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.1+1"
|
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:
|
json_rpc_2:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -753,5 +774,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "0.0.5"
|
version: "0.0.5"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.5.0 <3.0.0"
|
dart: ">=2.7.0 <3.0.0"
|
||||||
flutter: ">=1.12.13+hotfix.4 <2.0.0"
|
flutter: ">=1.12.13+hotfix.4 <2.0.0"
|
||||||
|
@ -35,6 +35,7 @@ dependencies:
|
|||||||
yaml_serializer: ^0.0.5
|
yaml_serializer: ^0.0.5
|
||||||
connectivity: ^0.4.6+1
|
connectivity: ^0.4.6+1
|
||||||
flutter_emoji: ">= 2.0.0"
|
flutter_emoji: ">= 2.0.0"
|
||||||
|
git_url_parse2: ^0.0.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_launcher_icons: "^0.7.2"
|
flutter_launcher_icons: "^0.7.2"
|
||||||
|
Reference in New Issue
Block a user