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

Side by Side Diff: runtime/bin/builtin.dart

Issue 321543003: New, more validating, parser for URI. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: One more test. 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library builtin; 5 library builtin;
6 import 'dart:io'; 6 import 'dart:io';
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 // import 'root_library'; happens here from C Code 9 // import 'root_library'; happens here from C Code
10 10
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return '/${cwd[0]}:'; 208 return '/${cwd[0]}:';
209 } 209 }
210 return null; 210 return null;
211 } 211 }
212 212
213 213
214 void _setWorkingDirectory(cwd) { 214 void _setWorkingDirectory(cwd) {
215 _workingWindowsDrivePrefix = _extractDriveLetterPrefix(cwd); 215 _workingWindowsDrivePrefix = _extractDriveLetterPrefix(cwd);
216 cwd = _sanitizeWindowsPath(cwd); 216 cwd = _sanitizeWindowsPath(cwd);
217 cwd = _enforceTrailingSlash(cwd); 217 cwd = _enforceTrailingSlash(cwd);
218 _workingDirectoryUri = new Uri(scheme: 'file', path: cwd); 218 _workingDirectoryUri = new Uri.file(cwd);
219 if (!_workingDirectoryUri.path.endsWith("/")) {
220 var directoryPath = _workingDirectoryUri.path + "/";
221 _workingDirectoryUri = _workingDirectoryUri.resolve(directoryPath);
222 }
223
219 _logResolution('# Working Directory: $cwd'); 224 _logResolution('# Working Directory: $cwd');
220 } 225 }
221 226
222 227
223 _setPackageRoot(String packageRoot) { 228 _setPackageRoot(String packageRoot) {
224 packageRoot = _enforceTrailingSlash(packageRoot); 229 packageRoot = _enforceTrailingSlash(packageRoot);
225 if (packageRoot.startsWith('file:') || 230 if (packageRoot.startsWith('file:') ||
226 packageRoot.startsWith('http:') || 231 packageRoot.startsWith('http:') ||
227 packageRoot.startsWith('https:')) { 232 packageRoot.startsWith('https:')) {
228 _packageRoot = _workingDirectoryUri.resolve(packageRoot); 233 _packageRoot = _workingDirectoryUri.resolve(packageRoot);
229 } else { 234 } else {
230 _packageRoot = _workingDirectoryUri.resolveUri(new Uri.file(packageRoot)); 235 _packageRoot = _workingDirectoryUri.resolveUri(new Uri.file(packageRoot));
231 } 236 }
232 _logResolution('# Package root: $packageRoot -> $_packageRoot'); 237 _logResolution('# Package root: $packageRoot -> $_packageRoot');
233 } 238 }
234 239
235 240
236 String _resolveScriptUri(String scriptName) { 241 String _resolveScriptUri(String scriptName) {
237 if (_workingDirectoryUri == null) { 242 if (_workingDirectoryUri == null) {
238 throw 'No current working directory set.'; 243 throw 'No current working directory set.';
239 } 244 }
240 scriptName = _sanitizeWindowsPath(scriptName); 245 scriptName = _sanitizeWindowsPath(scriptName);
241 246 var scriptUri;
242 var scriptUri = Uri.parse(scriptName); 247 if (scriptName.startsWith("file:") ||
248 scriptName.startsWith("http:") ||
249 scriptName.startsWith("https:")) {
250 scriptUri = Uri.parse(scriptName);
251 } else {
252 // Assume it's a file name.
253 scriptUri = new Uri.file(scriptName);
254 }
243 if (scriptUri.scheme != '') { 255 if (scriptUri.scheme != '') {
244 // Script has a scheme, assume that it is fully formed. 256 // Script has a scheme, assume that it is fully formed.
245 _entryPointScript = scriptUri; 257 _entryPointScript = scriptUri;
246 } else { 258 } else {
247 // Script does not have a scheme, assume that it is a path, 259 // Script does not have a scheme, assume that it is a path,
248 // resolve it against the working directory. 260 // resolve it against the working directory.
249 _entryPointScript = _workingDirectoryUri.resolve(scriptName); 261 _entryPointScript = _workingDirectoryUri.resolve(scriptName);
250 } 262 }
251 _logResolution('# Resolved entry point to: $_entryPointScript'); 263 _logResolution('# Resolved entry point to: $_entryPointScript');
252 return _entryPointScript.toString(); 264 return _entryPointScript.toString();
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } else if (Platform.isWindows) { 454 } else if (Platform.isWindows) {
443 filename = '$name.dll'; 455 filename = '$name.dll';
444 } else { 456 } else {
445 _logResolution( 457 _logResolution(
446 'Native extensions not supported on ${Platform.operatingSystem}'); 458 'Native extensions not supported on ${Platform.operatingSystem}');
447 throw 'Native extensions not supported on ${Platform.operatingSystem}'; 459 throw 'Native extensions not supported on ${Platform.operatingSystem}';
448 } 460 }
449 461
450 return [path, filename, name]; 462 return [path, filename, name];
451 } 463 }
OLDNEW
« 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