mirror of
https://github.com/dart-lang/sdk
synced 2024-09-22 15:13:31 +00:00
037b2f8c60
svn mv lib/sdk svn mv lib/sdk/compiler sdk/lib/_internal svn mv pkg/dartdoc sdk/lib/_internal (cannot gcl upload due to .png's in dartdoc) TBR=iposva git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14473 260f80e4-7a28-3924-810f-c04153c831b5
28 lines
881 B
Dart
28 lines
881 B
Dart
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
String merge(String base, String reference) {
|
|
if (base == "") return "/$reference";
|
|
return "${base.substring(0, base.lastIndexOf("/") + 1)}$reference";
|
|
}
|
|
|
|
String removeDotSegments(String path) {
|
|
List<String> output = [];
|
|
bool appendSlash = false;
|
|
for (String segment in path.split("/")) {
|
|
appendSlash = false;
|
|
if (segment == "..") {
|
|
if (!output.isEmpty &&
|
|
((output.length != 1) || (output[0] != ""))) output.removeLast();
|
|
appendSlash = true;
|
|
} else if ("." == segment) {
|
|
appendSlash = true;
|
|
} else {
|
|
output.add(segment);
|
|
}
|
|
}
|
|
if (appendSlash) output.add("");
|
|
return Strings.join(output, "/");
|
|
}
|