| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // TODO(nweiz): Avoid importing dart:io directly when cross-platform libraries | 5 // TODO(nweiz): Avoid importing dart:io directly when cross-platform libraries |
| 6 // exist. | 6 // exist. |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:convert'; | 10 import 'dart:convert'; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if (uri is Uri) return uri; | 70 if (uri is Uri) return uri; |
| 71 if (uri is String) return Uri.parse(uri); | 71 if (uri is String) return Uri.parse(uri); |
| 72 | 72 |
| 73 throw new ArgumentError.value(uri, name, "Must be a String or a Uri."); | 73 throw new ArgumentError.value(uri, name, "Must be a String or a Uri."); |
| 74 } | 74 } |
| 75 | 75 |
| 76 /// Returns a copy of [uri] with a trailing slash. | 76 /// Returns a copy of [uri] with a trailing slash. |
| 77 /// | 77 /// |
| 78 /// If [uri] already ends in a slash, returns it as-is. | 78 /// If [uri] already ends in a slash, returns it as-is. |
| 79 Uri ensureTrailingSlash(Uri uri) { | 79 Uri ensureTrailingSlash(Uri uri) { |
| 80 if (uri.pathSegments.isEmpty) return uri.replace(path: "/"); |
| 80 if (uri.pathSegments.last.isEmpty) return uri; | 81 if (uri.pathSegments.last.isEmpty) return uri; |
| 81 return uri.replace(pathSegments: uri.pathSegments.toList()..add("")); | 82 return uri.replace(pathSegments: uri.pathSegments.toList()..add("")); |
| 82 } | 83 } |
| OLD | NEW |