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

Unified Diff: sdk/lib/_internal/pub/lib/src/command/serve.dart

Issue 22887039: Normalize incoming AssetID paths. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 4 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 | « pkg/pkg.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/command/serve.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command/serve.dart b/sdk/lib/_internal/pub/lib/src/command/serve.dart
index ad891dc398f9c860d8614459e3189f3987a6829c..63934280d8204a3e76bad095c709369b6819fc52 100644
--- a/sdk/lib/_internal/pub/lib/src/command/serve.dart
+++ b/sdk/lib/_internal/pub/lib/src/command/serve.dart
@@ -226,7 +226,8 @@ class ServeCommand extends PubCommand {
var subdirectory = path.join(packageDir, name);
var watcher = new DirectoryWatcher(subdirectory);
watcher.events.listen((event) {
- var id = pathToAssetId(package, packageDir, event.path);
+ var id = new AssetId(package,
+ path.relative(event.path, from: packageDir));
if (event.type == ChangeType.REMOVE) {
_barback.removeSources([id]);
} else {
@@ -256,7 +257,8 @@ class ServeCommand extends PubCommand {
// Skip directories.
if (!fileExists(entry)) continue;
- files.add(pathToAssetId(package, packageDir, entry));
+ var id = new AssetId(package, path.relative(entry, from: packageDir));
+ files.add(id);
}
}
@@ -270,14 +272,4 @@ class ServeCommand extends PubCommand {
if (package == entrypoint.root.name) directories.add("web");
return directories;
}
-
- /// Converts a local file path to an [AssetId].
- AssetId pathToAssetId(String package, String packageDir, String filePath) {
- var relative = path.relative(filePath, from: packageDir);
-
- // AssetId paths use "/" on all platforms.
- relative = path.toUri(relative).path;
-
- return new AssetId(package, relative);
- }
}
« no previous file with comments | « pkg/pkg.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698