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

Unified Diff: utils/pub/validator/name.dart

Issue 12328021: Make sure package names are URL encoded. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: URL encode version too. 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 | « utils/pub/hosted_source.dart ('k') | utils/tests/pub/install/hosted/install_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/validator/name.dart
diff --git a/utils/pub/validator/name.dart b/utils/pub/validator/name.dart
index a0ca81ad65f03139533d42a8ecb0957071142d97..c183f9c0db927c6a6ffa128cb6439e5d5b2c22cf 100644
--- a/utils/pub/validator/name.dart
+++ b/utils/pub/validator/name.dart
@@ -65,17 +65,19 @@ class NameValidator extends Validator {
}
void _checkName(String name, String description, {bool isPackage}) {
+ // Packages names are more stringent than libraries.
+ var messages = isPackage ? errors : warnings;
+
if (name == "") {
errors.add("$description may not be empty.");
} else if (!new RegExp(r"^[a-zA-Z0-9_]*$").hasMatch(name)) {
- warnings.add("$description may only contain letters, numbers, and "
+ messages.add("$description may only contain letters, numbers, and "
"underscores.\n"
"Using a valid Dart identifier makes the name usable in Dart code.");
} else if (!new RegExp(r"^[a-zA-Z]").hasMatch(name)) {
- warnings.add("$description must begin with letter.\n"
+ messages.add("$description must begin with letter.\n"
"Using a valid Dart identifier makes the name usable in Dart code.");
} else if (_RESERVED_WORDS.contains(name.toLowerCase())) {
- var messages = isPackage ? errors : warnings;
messages.add("$description may not be a reserved word in Dart.\n"
"Using a valid Dart identifier makes the name usable in Dart code.");
} else if (new RegExp(r"[A-Z]").hasMatch(name)) {
« no previous file with comments | « utils/pub/hosted_source.dart ('k') | utils/tests/pub/install/hosted/install_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698