OLD | NEW |
---|---|
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 | 7 |
8 int _httpRequestResponseCode = 0; | 8 int _httpRequestResponseCode = 0; |
9 String _httpRequestStatusString; | 9 String _httpRequestStatusString; |
10 List<int> _httpRequestResponse; | 10 List<int> _httpRequestResponse; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 _setPackageRoot(String packageRoot) { | 68 _setPackageRoot(String packageRoot) { |
69 // TODO(mattsh) - refactor windows drive and path handling code | 69 // TODO(mattsh) - refactor windows drive and path handling code |
70 // so it can be used here if needed. | 70 // so it can be used here if needed. |
71 _packageRoot = packageRoot; | 71 _packageRoot = packageRoot; |
72 } | 72 } |
73 | 73 |
74 String _resolveScriptUri(String cwd, String scriptName, bool isWindows) { | 74 String _resolveScriptUri(String cwd, String scriptName, bool isWindows) { |
75 var scriptUri = Uri.parse(scriptName); | |
76 if (scriptUri.scheme == 'http') { | |
Søren Gjesse
2013/06/03 07:12:07
How about https?
Ivan Posva
2013/06/03 07:22:56
What if the URI we were handed on the command line
Cutch
2013/06/03 17:55:37
Now that we are using the dart:io HttpClient we ca
Cutch
2013/06/03 17:55:37
Agreed. This code needs to be cleaned up. I'll do
| |
77 _entrypoint = scriptUri; | |
78 _logResolution("# Resolved script to: $_entrypoint"); | |
79 return _entrypoint.toString(); | |
80 } | |
75 _logResolution("# Current working directory: $cwd"); | 81 _logResolution("# Current working directory: $cwd"); |
76 _logResolution("# ScriptName: $scriptName"); | 82 _logResolution("# ScriptName: $scriptName"); |
77 if (isWindows) { | 83 if (isWindows) { |
78 // For Windows we need to massage the paths a bit according to | 84 // For Windows we need to massage the paths a bit according to |
79 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx | 85 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx |
80 // | 86 // |
81 // Convert | 87 // Convert |
82 // C:\one\two\three | 88 // C:\one\two\three |
83 // to | 89 // to |
84 // /C:/one/two/three | 90 // /C:/one/two/three |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 var path = (uri.path != '') ? '${uri.host}${uri.path}' : uri.host; | 192 var path = (uri.path != '') ? '${uri.host}${uri.path}' : uri.host; |
187 var right = 'package:$path'; | 193 var right = 'package:$path'; |
188 var wrong = 'package://$path'; | 194 var wrong = 'package://$path'; |
189 | 195 |
190 throw "URIs using the 'package:' scheme should look like " | 196 throw "URIs using the 'package:' scheme should look like " |
191 "'$right', not '$wrong'."; | 197 "'$right', not '$wrong'."; |
192 } | 198 } |
193 | 199 |
194 var path; | 200 var path; |
195 if (_packageRoot != null) { | 201 if (_packageRoot != null) { |
196 path = "${_packageRoot}${uri.path}"; | 202 path = "${_packageRoot}${uri.path}"; |
Ivan Posva
2013/06/03 07:22:56
What is confusing in this whole scheme is that if
Cutch
2013/06/03 17:55:37
See my other comment. This function needs to be cl
| |
197 } else { | 203 } else { |
198 path = _entrypoint.resolve('packages/${uri.path}').path; | 204 if (_entrypoint.scheme == 'http') { |
Søren Gjesse
2013/06/03 07:12:07
Ditto.
| |
205 path = _entrypoint.resolve('packages/${uri.path}').toString(); | |
206 } else { | |
207 path = _entrypoint.resolve('packages/${uri.path}').path; | |
208 } | |
199 } | 209 } |
200 | 210 |
201 _logResolution("# Package: $path"); | 211 _logResolution("# Package: $path"); |
202 return path; | 212 return path; |
203 } | 213 } |
204 | 214 |
205 String _filePathFromHttpUri(Uri uri) { | 215 String _filePathFromHttpUri(Uri uri) { |
206 _logResolution('# Path: $uri'); | 216 _logResolution('# Path: $uri'); |
207 return uri.toString(); | 217 return uri.toString(); |
208 } | 218 } |
OLD | NEW |