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

Unified Diff: utils/pub/pubspec.dart

Issue 12211097: Added support for 'description' in pubspec.yaml. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | utils/tests/pub/pubspec_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/pubspec.dart
diff --git a/utils/pub/pubspec.dart b/utils/pub/pubspec.dart
index f7c3579325c313111ec14cc705f20c18d7c7dd63..779a29490dde802ead5d07764cc71451c645ca62 100644
--- a/utils/pub/pubspec.dart
+++ b/utils/pub/pubspec.dart
@@ -132,19 +132,10 @@ class Pubspec {
// and also expose it to the editor in some way.
if (parsedPubspec.containsKey('homepage')) {
- var homepage = parsedPubspec['homepage'];
-
- if (homepage is! String) {
- throw new FormatException(
- 'The "homepage" field should be a string, but was "$homepage".');
- }
-
- var goodScheme = new RegExp(r'^https?:');
- if (!goodScheme.hasMatch(homepage)) {
- throw new FormatException(
- 'The "homepage" field should be an "http:" or "https:" URL, but '
- 'was "$homepage".');
- }
+ _validateFieldUrl(parsedPubspec['homepage'], 'homepage');
+ }
+ if (parsedPubspec.containsKey('documentation')) {
+ _validateFieldUrl(parsedPubspec['documentation'], 'documentation');
}
if (parsedPubspec.containsKey('author') &&
@@ -177,6 +168,25 @@ class Pubspec {
}
}
+/**
+ * Evaluates whether the given [url] for [field] is valid.
+ *
+ * Throws [FormatException] on an invalid url.
+ */
+void _validateFieldUrl(url, String field) {
+ if (url is! String) {
+ throw new FormatException(
+ 'The "$field" field should be a string, but was "$url".');
+ }
+
+ var goodScheme = new RegExp(r'^https?:');
+ if (!goodScheme.hasMatch(url)) {
+ throw new FormatException(
+ 'The "$field" field should be an "http:" or "https:" URL, but '
+ 'was "$url".');
+ }
+}
+
List<PackageRef> _parseDependencies(SourceRegistry sources, yaml) {
var dependencies = <PackageRef>[];
« no previous file with comments | « no previous file | utils/tests/pub/pubspec_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698