Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: dart/lib/uri/helpers.dart

Issue 10383103: Split the URI library across multiple files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/lib/uri/uri.dart » ('j') | dart/lib/uri/uri.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/uri/helpers.dart
diff --git a/dart/lib/uri/helpers.dart b/dart/lib/uri/helpers.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b23cdb8598f2645f9a964f2ffa7e1c437dd4be3c
--- /dev/null
+++ b/dart/lib/uri/helpers.dart
@@ -0,0 +1,27 @@
+// 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) {
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
+ appendSlash = true;
+ } else {
+ output.add(segment);
+ }
+ }
+ if (appendSlash) output.add("");
+ return Strings.join(output, "/");
+}
« no previous file with comments | « no previous file | dart/lib/uri/uri.dart » ('j') | dart/lib/uri/uri.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698