Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1322)

Unified Diff: lib/src/source/git.dart

Issue 1555133002: Don't choke on SSH Git URLs. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/source/git.dart
diff --git a/lib/src/source/git.dart b/lib/src/source/git.dart
index 06981fab70f821a28b3836f5956bd46a29c45f58..8fc1014606c7ed274a503983b859b7fb83dce696 100644
--- a/lib/src/source/git.dart
+++ b/lib/src/source/git.dart
@@ -135,8 +135,7 @@ class GitSource extends CachedSource {
"string.");
}
- // Ensure that it's a valid URL.
- Uri.parse(description["url"]);
+ _validateUrl(description["url"]);
var ref = description["ref"];
if (ref != null && ref is! String) {
@@ -161,8 +160,7 @@ class GitSource extends CachedSource {
"string.");
}
- // Ensure that it's a valid URL.
- Uri.parse(description["url"]);
+ _validateUrl(description["url"]);
var ref = description["ref"];
if (ref != null && ref is! String) {
@@ -182,6 +180,16 @@ class GitSource extends CachedSource {
});
}
+ /// Throws a [FormatException] if [url] isn't a valid Git URL.
+ void _validateUrl(String url) {
+ // If the URL contains an @, it's probably an SSH hostname, which we don't
+ // know how to validate.
+ if (url.contains("@")) return;
+
+ // Otherwise, we use Dart's URL parser to validate the URL.
+ Uri.parse(url);
+ }
+
/// If [description] has a resolved ref, print it out in short-form.
///
/// This helps distinguish different git commits with the same pubspec
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698