OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 String merge(String base, String reference) { | |
6 if (base == "") return "/$reference"; | |
7 return "${base.substring(0, base.lastIndexOf("/") + 1)}$reference"; | |
8 } | |
9 | |
10 String removeDotSegments(String path) { | |
11 List<String> output = []; | |
12 bool appendSlash = false; | |
13 for (String segment in path.split("/")) { | |
14 appendSlash = false; | |
15 if (segment == "..") { | |
16 if (!output.isEmpty() && | |
17 ((output.length != 1) || (output[0] != ""))) output.removeLast(); | |
18 appendSlash = true; | |
19 } else if ("." == segment) { | |
ngeoffray
2012/05/11 12:41:23
consistency: put segment lhs
ahe
2012/05/11 12:51:32
I did not change this code (but I think I wrote it
| |
20 appendSlash = true; | |
21 } else { | |
22 output.add(segment); | |
23 } | |
24 } | |
25 if (appendSlash) output.add(""); | |
26 return Strings.join(output, "/"); | |
27 } | |
OLD | NEW |