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 http_server; | 5 library http_server; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 Path _getFilePathFromRequestPath(String urlRequestPath) { | 182 Path _getFilePathFromRequestPath(String urlRequestPath) { |
183 // Go to the top of the file to see an explanation of the URL path scheme. | 183 // Go to the top of the file to see an explanation of the URL path scheme. |
184 var requestPath = new Path(urlRequestPath.substring(1)).canonicalize(); | 184 var requestPath = new Path(urlRequestPath.substring(1)).canonicalize(); |
185 var pathSegments = requestPath.segments(); | 185 var pathSegments = requestPath.segments(); |
186 if (pathSegments.length > 0) { | 186 if (pathSegments.length > 0) { |
187 var basePath; | 187 var basePath; |
188 var relativePath; | 188 var relativePath; |
189 if (pathSegments[0] == PREFIX_BUILDDIR) { | 189 if (pathSegments[0] == PREFIX_BUILDDIR) { |
190 basePath = _buildDirectory; | 190 basePath = _buildDirectory; |
191 relativePath = new Path( | 191 relativePath = new Path( |
192 pathSegments.getRange(1, pathSegments.length - 1).join('/')); | 192 pathSegments.skip(1).join('/')); |
193 } else if (pathSegments[0] == PREFIX_DARTDIR) { | 193 } else if (pathSegments[0] == PREFIX_DARTDIR) { |
194 basePath = TestUtils.dartDir(); | 194 basePath = TestUtils.dartDir(); |
195 relativePath = new Path( | 195 relativePath = new Path( |
196 pathSegments.getRange(1, pathSegments.length - 1).join('/')); | 196 pathSegments.skip(1).join('/')); |
197 } | 197 } |
198 var packagesDirName = 'packages'; | 198 var packagesDirName = 'packages'; |
199 var packagesIndex = pathSegments.indexOf(packagesDirName); | 199 var packagesIndex = pathSegments.indexOf(packagesDirName); |
200 if (packagesIndex != -1) { | 200 if (packagesIndex != -1) { |
201 var start = packagesIndex + 1; | 201 var start = packagesIndex + 1; |
202 var length = pathSegments.length - start; | |
203 basePath = _buildDirectory.append(packagesDirName); | 202 basePath = _buildDirectory.append(packagesDirName); |
204 relativePath = new Path( | 203 relativePath = new Path(pathSegments.skip(start).join('/')); |
205 pathSegments.getRange(start, length).join('/')); | |
206 } | 204 } |
207 if (basePath != null && relativePath != null) { | 205 if (basePath != null && relativePath != null) { |
208 return basePath.join(relativePath); | 206 return basePath.join(relativePath); |
209 } | 207 } |
210 } | 208 } |
211 return null; | 209 return null; |
212 } | 210 } |
213 | 211 |
214 Future<List<_Entry>> _listDirectory(Directory directory) { | 212 Future<List<_Entry>> _listDirectory(Directory directory) { |
215 var completer = new Completer(); | 213 var completer = new Completer(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 class _Entry { | 321 class _Entry { |
324 final String name; | 322 final String name; |
325 final String displayName; | 323 final String displayName; |
326 | 324 |
327 _Entry(this.name, this.displayName); | 325 _Entry(this.name, this.displayName); |
328 | 326 |
329 int compareTo(_Entry other) { | 327 int compareTo(_Entry other) { |
330 return name.compareTo(other.name); | 328 return name.compareTo(other.name); |
331 } | 329 } |
332 } | 330 } |
OLD | NEW |