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

Unified Diff: lib/packages_file.dart

Issue 1227283002: Don't allow package:-URIs as package locations when creating .packages file. (Closed) Base URL: https://github.com/dart-lang/package_config.git@master
Patch Set: Fix unrelated typo. Created 5 years, 5 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 | « lib/discovery.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/packages_file.dart
diff --git a/lib/packages_file.dart b/lib/packages_file.dart
index 73e6061c9f6faf12a74e54123b13aa924cecfc8c..25d2d6883bb29ad774192cf37bf42e9443dd64ea 100644
--- a/lib/packages_file.dart
+++ b/lib/packages_file.dart
@@ -80,6 +80,9 @@ Map<String, Uri> parse(List<int> source, Uri baseLocation) {
///
/// If [baseUri] is provided, package locations will be made relative
/// to the base URI, if possible, before writing.
+///
+/// All the keys of [packageMapping] must be valid package names,
+/// and the values must be URIs that do not have the `package:` scheme.
void write(StringSink output, Map<String, Uri> packageMapping,
{Uri baseUri, String comment}) {
if (baseUri != null && !baseUri.isAbsolute) {
@@ -104,6 +107,10 @@ void write(StringSink output, Map<String, Uri> packageMapping,
if (!isValidPackageName(packageName)) {
throw new ArgumentError('"$packageName" is not a valid package name');
}
+ if (uri.scheme == "package") {
+ throw new ArgumentError.value(
+ "Package location must not be a package: URI", uri);
+ }
output.write(packageName);
output.write(':');
// If baseUri provided, make uri relative.
« no previous file with comments | « lib/discovery.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698