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

Unified Diff: client/util/Uri.dart

Issue 9382027: Move client/{base, observable, layout, touch, util, view} to samples/ui_lib . (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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 | « client/util/StringUtils.dart ('k') | client/util/utilslib.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/util/Uri.dart
===================================================================
--- client/util/Uri.dart (revision 4144)
+++ client/util/Uri.dart (working copy)
@@ -1,77 +0,0 @@
-// 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.
-
-/**
- * A parsed URI, inspired by:
- * http://closure-library.googlecode.com/svn/docs/class_goog_Uri.html
- */
-class Uri extends uri.Uri {
- /**
- * Parses a URL query string into a map. Because you can have multiple values
- * for the same parameter name, each parameter name maps to a list of
- * values. For example, '?a=b&c=d&a=e' would be parsed as
- * [{'a':['b','e'],'c':['d']}].
- */
- // TODO(jmesserly): consolidate with new Uri.fromString(...)
- static Map<String, List<String>> parseQuery(String queryString) {
- final queryParams = new Map<String, List<String>>();
- if (queryString.startsWith('?')) {
- final params = queryString.substring(1, queryString.length).split('&');
- for (final param in params) {
- List<String> parts = param.split('=');
- if (parts.length == 2) {
- // TODO(hiltonc) the name and value should be URL decoded.
- String name = parts[0];
- String value = parts[1];
-
- // Create a list of values for this name if not yet done.
- List values = queryParams[name];
- if (values === null) {
- values = new List();
- queryParams[name] = values;
- }
-
- values.add(value);
- }
- }
- }
- return queryParams;
- }
-
- /**
- * Percent-encodes a string for use as a query parameter in a URI.
- */
- // TODO(rnystrom): Get rid of this when the real encodeURIComponent()
- // function is available within Dart.
- static String encodeComponent(String component) {
- if (component == null) return component;
-
- // TODO(terry): Added b/5096547 to track replace should by default behave
- // like replaceAll to avoid a problematic usage pattern.
- return component.replaceAll(':', '%3A')
- .replaceAll('/', '%2F')
- .replaceAll('?', '%3F')
- .replaceAll('=', '%3D')
- .replaceAll('&', '%26')
- .replaceAll(' ', '%20');
- }
-
- /**
- * Decodes a string used a query parameter by replacing percent-encoded
- * sequences with their original characters.
- */
- // TODO(jmesserly): replace this with a better implementation
- static String decodeComponent(String component) {
- if (component == null) return component;
-
- return component.replaceAll('%3A', ':')
- .replaceAll('%2F', '/')
- .replaceAll('%3F', '?')
- .replaceAll('%3D', '=')
- .replaceAll('%26', '&')
- .replaceAll('%20', ' ');
- }
-
- Uri.fromString(String uri) : super.fromString(uri);
-}
« no previous file with comments | « client/util/StringUtils.dart ('k') | client/util/utilslib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698