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

Unified Diff: runtime/bin/builtin.dart

Issue 339563003: Another case of VM using Uri.resolve on something not a URI reference. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin.dart
diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart
index 046c6e088f8d0ccb6c786d36442d80b83e38b1a0..e2c409b7480f0b2bedabc37331fc49cd00a6e663 100644
--- a/runtime/bin/builtin.dart
+++ b/runtime/bin/builtin.dart
@@ -197,16 +197,19 @@ void _setWorkingDirectory(cwd) {
_logResolution('# Working Directory: $cwd');
}
+Uri _uriFromPathOrUri(String location) {
+ if (location.startsWith('file:') ||
+ location.startsWith('http:') ||
+ location.startsWith('https:')) {
+ return Uri.parse(location);
+ }
+ return new Uri.file(location);
+}
_setPackageRoot(String packageRoot) {
packageRoot = _enforceTrailingSlash(packageRoot);
- if (packageRoot.startsWith('file:') ||
- packageRoot.startsWith('http:') ||
- packageRoot.startsWith('https:')) {
- _packageRoot = _workingDirectoryUri.resolve(packageRoot);
- } else {
- _packageRoot = _workingDirectoryUri.resolveUri(new Uri.file(packageRoot));
- }
+ _packageRoot =
+ _workingDirectoryUri.resolveUri(_uriFromPathOrUri(packageRoot));
_logResolution('# Package root: $packageRoot -> $_packageRoot');
}
@@ -215,15 +218,7 @@ String _resolveScriptUri(String scriptName) {
if (_workingDirectoryUri == null) {
throw 'No current working directory set.';
}
- var scriptUri;
- if (scriptName.startsWith("file:") ||
- scriptName.startsWith("http:") ||
- scriptName.startsWith("https:")) {
- scriptUri = Uri.parse(scriptName);
- } else {
- // Assume it's a file name.
- scriptUri = new Uri.file(scriptName);
- }
+ var scriptUri = _uriFromPathOrUri(scriptName);
if (scriptUri.scheme != '') {
// Script has a scheme, assume that it is fully formed.
_entryPointScript = scriptUri;
@@ -326,7 +321,7 @@ void _asyncLoadError(uri, error) {
// an http or file uri.
_loadDataAsync(String uri) {
uri = _resolveScriptUri(uri);
- Uri sourceUri = Uri.parse(uri);
+ Uri sourceUri = _uriFromPathOrUri(uri);
_numOutstandingLoadRequests++;
_logResolution("_loadDataAsync($uri), "
"${_numOutstandingLoadRequests} requests outstanding");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698