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

Unified Diff: runtime/bin/builtin.dart

Issue 337033003: Revert "New, more validating, parser for URI." and follow-up patches. (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 | « pkg/json_rpc_2/test/server/parameters_test.dart ('k') | sdk/lib/core/uri.dart » ('j') | 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 3931c5947b1ea460e2c9cedd2d1bab1da2f46d1d..8f6ea77564c2771e59a27500c670b3548c73776c 100644
--- a/runtime/bin/builtin.dart
+++ b/runtime/bin/builtin.dart
@@ -166,6 +166,31 @@ void _setWindows() {
}
+_sanitizeWindowsPath(path) {
+ // For Windows we need to massage the paths a bit according to
+ // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
+ //
+ // Convert
+ // C:\one\two\three
+ // to
+ // /C:/one/two/three
+
+ if (_isWindows == false) {
+ // Do nothing when not running Windows.
+ return path;
+ }
+
+ var fixedPath = "${path.replaceAll('\\', '/')}";
+
+ if ((path.length > 2) && (path[1] == ':')) {
+ // Path begins with a drive letter.
+ return '/$fixedPath';
+ }
+
+ return fixedPath;
+}
+
+
_enforceTrailingSlash(uri) {
// Ensure we have a trailing slash character.
if (!uri.endsWith('/')) {
@@ -188,28 +213,22 @@ _extractDriveLetterPrefix(cwd) {
void _setWorkingDirectory(cwd) {
_workingWindowsDrivePrefix = _extractDriveLetterPrefix(cwd);
- _workingDirectoryUri = new Uri.file(cwd);
- if (!_workingDirectoryUri.path.endsWith("/")) {
- var directoryPath = _workingDirectoryUri.path + "/";
- _workingDirectoryUri = _workingDirectoryUri.resolve(directoryPath);
- }
-
+ cwd = _sanitizeWindowsPath(cwd);
+ cwd = _enforceTrailingSlash(cwd);
+ _workingDirectoryUri = new Uri(scheme: 'file', path: 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);
- _packageRoot =
- _workingDirectoryUri.resolveUri(_uriFromPathOrUri(packageRoot));
+ if (packageRoot.startsWith('file:') ||
+ packageRoot.startsWith('http:') ||
+ packageRoot.startsWith('https:')) {
+ _packageRoot = _workingDirectoryUri.resolve(packageRoot);
+ } else {
+ _packageRoot = _workingDirectoryUri.resolveUri(new Uri.file(packageRoot));
+ }
_logResolution('# Package root: $packageRoot -> $_packageRoot');
}
@@ -218,7 +237,9 @@ String _resolveScriptUri(String scriptName) {
if (_workingDirectoryUri == null) {
throw 'No current working directory set.';
}
- var scriptUri = _uriFromPathOrUri(scriptName);
+ scriptName = _sanitizeWindowsPath(scriptName);
+
+ var scriptUri = Uri.parse(scriptName);
if (scriptUri.scheme != '') {
// Script has a scheme, assume that it is fully formed.
_entryPointScript = scriptUri;
@@ -321,7 +342,7 @@ void _asyncLoadError(uri, error) {
// an http or file uri.
_loadDataAsync(String uri) {
uri = _resolveScriptUri(uri);
- Uri sourceUri = _uriFromPathOrUri(uri);
+ Uri sourceUri = Uri.parse(uri);
_numOutstandingLoadRequests++;
_logResolution("_loadDataAsync($uri), "
"${_numOutstandingLoadRequests} requests outstanding");
@@ -362,7 +383,7 @@ void _loadLibrarySource(tag, uri, libraryUri, text) {
// Asynchronously loads source code through an http or file uri.
_loadSourceAsync(int tag, String uri, String libraryUri) {
var filePath = _filePathFromUri(uri);
- Uri sourceUri = new Uri.file(filePath);
+ Uri sourceUri = Uri.parse(filePath);
_numOutstandingLoadRequests++;
_logResolution("_loadLibrarySource($uri), "
"${_numOutstandingLoadRequests} requests outstanding");
« no previous file with comments | « pkg/json_rpc_2/test/server/parameters_test.dart ('k') | sdk/lib/core/uri.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698