Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 Path _getFilePathFromRequestPath(String urlRequestPath) { | 189 Path _getFilePathFromRequestPath(String urlRequestPath) { |
| 190 // Go to the top of the file to see an explanation of the URL path scheme. | 190 // Go to the top of the file to see an explanation of the URL path scheme. |
| 191 var requestPath = new Path(urlRequestPath.substring(1)).canonicalize(); | 191 var requestPath = new Path(urlRequestPath.substring(1)).canonicalize(); |
| 192 var pathSegments = requestPath.segments(); | 192 var pathSegments = requestPath.segments(); |
| 193 if (pathSegments.length > 0) { | 193 if (pathSegments.length > 0) { |
| 194 var basePath; | 194 var basePath; |
| 195 var relativePath; | 195 var relativePath; |
| 196 if (pathSegments[0] == PREFIX_BUILDDIR) { | 196 if (pathSegments[0] == PREFIX_BUILDDIR) { |
| 197 basePath = _buildDirectory; | 197 basePath = _buildDirectory; |
| 198 relativePath = new Path( | 198 relativePath = new Path( |
| 199 pathSegments.getRange(1, pathSegments.length - 1).join('/')); | 199 pathSegments.sublist(1).join('/')); |
|
floitsch
2013/03/14 15:46:06
In theory pathSegments.skip(1).join('/') would be
Lasse Reichstein Nielsen
2013/03/15 09:13:09
This code is in the testing directory, so I'll rev
| |
| 200 } else if (pathSegments[0] == PREFIX_DARTDIR) { | 200 } else if (pathSegments[0] == PREFIX_DARTDIR) { |
| 201 basePath = TestUtils.dartDir(); | 201 basePath = TestUtils.dartDir(); |
| 202 relativePath = new Path( | 202 relativePath = new Path( |
| 203 pathSegments.getRange(1, pathSegments.length - 1).join('/')); | 203 pathSegments.sublist(1).join('/')); |
| 204 } | 204 } |
| 205 var packagesDirName = 'packages'; | 205 var packagesDirName = 'packages'; |
| 206 var packagesIndex = pathSegments.indexOf(packagesDirName); | 206 var packagesIndex = pathSegments.indexOf(packagesDirName); |
| 207 if (packagesIndex != -1) { | 207 if (packagesIndex != -1) { |
| 208 var start = packagesIndex + 1; | 208 var start = packagesIndex + 1; |
| 209 var length = pathSegments.length - start; | |
| 210 basePath = _buildDirectory.append(packagesDirName); | 209 basePath = _buildDirectory.append(packagesDirName); |
| 211 relativePath = new Path( | 210 relativePath = new Path( |
| 212 pathSegments.getRange(start, length).join('/')); | 211 pathSegments.sublist(start).join('/')); |
| 213 } | 212 } |
| 214 if (basePath != null && relativePath != null) { | 213 if (basePath != null && relativePath != null) { |
| 215 return basePath.join(relativePath); | 214 return basePath.join(relativePath); |
| 216 } | 215 } |
| 217 } | 216 } |
| 218 return null; | 217 return null; |
| 219 } | 218 } |
| 220 | 219 |
| 221 Future<List<_Entry>> _listDirectory(Directory directory) { | 220 Future<List<_Entry>> _listDirectory(Directory directory) { |
| 222 var completer = new Completer(); | 221 var completer = new Completer(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 class _Entry { | 334 class _Entry { |
| 336 final String name; | 335 final String name; |
| 337 final String displayName; | 336 final String displayName; |
| 338 | 337 |
| 339 _Entry(this.name, this.displayName); | 338 _Entry(this.name, this.displayName); |
| 340 | 339 |
| 341 int compareTo(_Entry other) { | 340 int compareTo(_Entry other) { |
| 342 return name.compareTo(other.name); | 341 return name.compareTo(other.name); |
| 343 } | 342 } |
| 344 } | 343 } |
| OLD | NEW |