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 | 6 |
7 // Corelib 'print' implementation. | 7 // Corelib 'print' implementation. |
8 void _print(arg) { | 8 void _print(arg) { |
9 _Logger._printString(arg.toString()); | 9 _Logger._printString(arg.toString()); |
10 } | 10 } |
(...skipping 18 matching lines...) Expand all Loading... | |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 _setPackageRoot(String packageRoot) { | 32 _setPackageRoot(String packageRoot) { |
33 // TODO(mattsh) - refactor windows drive and path handling code | 33 // TODO(mattsh) - refactor windows drive and path handling code |
34 // so it can be used here if needed. | 34 // so it can be used here if needed. |
35 _packageRoot = packageRoot; | 35 _packageRoot = packageRoot; |
36 } | 36 } |
37 | 37 |
38 String _resolveScriptUri(String cwd, String scriptName, bool isWindows) { | 38 String _resolveScriptUri(String cwd, String scriptName, bool isWindows) { |
39 var scriptUri = Uri.parse(scriptName); | |
40 if (scriptUri.scheme == 'http') { | |
41 _entrypoint = scriptUri; | |
42 _logResolution("# Resolved script to: $_entrypoint"); | |
43 return _entrypoint.toString(); | |
44 } | |
39 _logResolution("# Current working directory: $cwd"); | 45 _logResolution("# Current working directory: $cwd"); |
40 _logResolution("# ScriptName: $scriptName"); | 46 _logResolution("# ScriptName: $scriptName"); |
41 if (isWindows) { | 47 if (isWindows) { |
42 // For Windows we need to massage the paths a bit according to | 48 // For Windows we need to massage the paths a bit according to |
43 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx | 49 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx |
44 // | 50 // |
45 // Convert | 51 // Convert |
46 // C:\one\two\three | 52 // C:\one\two\three |
47 // to | 53 // to |
48 // /C:/one/two/three | 54 // /C:/one/two/three |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 var wrong = 'package://$path'; | 158 var wrong = 'package://$path'; |
153 | 159 |
154 throw "URIs using the 'package:' scheme should look like " | 160 throw "URIs using the 'package:' scheme should look like " |
155 "'$right', not '$wrong'."; | 161 "'$right', not '$wrong'."; |
156 } | 162 } |
157 | 163 |
158 var path; | 164 var path; |
159 if (_packageRoot != null) { | 165 if (_packageRoot != null) { |
160 path = "${_packageRoot}${uri.path}"; | 166 path = "${_packageRoot}${uri.path}"; |
161 } else { | 167 } else { |
162 path = _entrypoint.resolve('packages/${uri.path}').path; | 168 if (_entrypoint.scheme == 'http') { |
169 path = _entrypoint.resolve('packages/${uri.path}').toString(); | |
170 } else { | |
171 path = _entrypoint.resolve('packages/${uri.path}').path; | |
172 } | |
163 } | 173 } |
164 | 174 |
165 _logResolution("# Package: $path"); | 175 _logResolution("# Package: $path"); |
166 return path; | 176 return path; |
167 } | 177 } |
168 | 178 |
169 String _filePathFromHttpUri(Uri uri) { | 179 String _filePathFromHttpUri(Uri uri) { |
170 _logResolution('# Path: $uri'); | 180 _logResolution('# Path: $uri'); |
171 return uri.toString(); | 181 return uri.toString(); |
172 } | 182 } |
173 | 183 |
174 String _pathFromHttpUri(String userUri) { | 184 String _pathFromHttpUri(String userUri) { |
175 var uri = Uri.parse(userUri); | 185 var uri = Uri.parse(userUri); |
176 return uri.path; | 186 return uri.path; |
177 } | 187 } |
178 | 188 |
179 String _domainFromHttpUri(String userUri) { | 189 String _hostFromHttpUri(String userUri) { |
180 var uri = Uri.parse(userUri); | 190 var uri = Uri.parse(userUri); |
181 return uri.domain; | 191 return uri.host; |
Søren Gjesse
2013/05/30 09:13:03
Sorry I missed this when landing the Uri change.
| |
182 } | 192 } |
183 | 193 |
184 int _portFromHttpUri(String userUri) { | 194 int _portFromHttpUri(String userUri) { |
185 var uri = Uri.parse(userUri); | 195 var uri = Uri.parse(userUri); |
186 return uri.port == 0 ? 80 : uri.port; | 196 return uri.port == 0 ? 80 : uri.port; |
187 } | 197 } |
OLD | NEW |