| 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>[];
|
|
|
|
|