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

Side by Side Diff: samples-dev/swarm/swarm_ui_lib/util/Uri.dart

Issue 2828603002: Format samples and samples-dev directories. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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 part of utilslib; 5 part of utilslib;
6 6
7 /** 7 /**
8 * A parsed URI, inspired by: 8 * A parsed URI, inspired by:
9 * http://closure-library.googlecode.com/svn/docs/class_goog_Uri.html 9 * http://closure-library.googlecode.com/svn/docs/class_goog_Uri.html
10 */ 10 */
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 /** 44 /**
45 * Percent-encodes a string for use as a query parameter in a URI. 45 * Percent-encodes a string for use as a query parameter in a URI.
46 */ 46 */
47 // TODO(rnystrom): Get rid of this when the real encodeURIComponent() 47 // TODO(rnystrom): Get rid of this when the real encodeURIComponent()
48 // function is available within Dart. 48 // function is available within Dart.
49 static String encodeComponent(String component) { 49 static String encodeComponent(String component) {
50 if (component == null) return component; 50 if (component == null) return component;
51 51
52 // TODO(terry): Added b/5096547 to track replace should by default behave 52 // TODO(terry): Added b/5096547 to track replace should by default behave
53 // like replaceAll to avoid a problematic usage pattern. 53 // like replaceAll to avoid a problematic usage pattern.
54 return component.replaceAll(':', '%3A') 54 return component
55 .replaceAll('/', '%2F') 55 .replaceAll(':', '%3A')
56 .replaceAll('?', '%3F') 56 .replaceAll('/', '%2F')
57 .replaceAll('=', '%3D') 57 .replaceAll('?', '%3F')
58 .replaceAll('&', '%26') 58 .replaceAll('=', '%3D')
59 .replaceAll(' ', '%20'); 59 .replaceAll('&', '%26')
60 .replaceAll(' ', '%20');
60 } 61 }
61 62
62 /** 63 /**
63 * Decodes a string used a query parameter by replacing percent-encoded 64 * Decodes a string used a query parameter by replacing percent-encoded
64 * sequences with their original characters. 65 * sequences with their original characters.
65 */ 66 */
66 // TODO(jmesserly): replace this with a better implementation 67 // TODO(jmesserly): replace this with a better implementation
67 static String decodeComponent(String component) { 68 static String decodeComponent(String component) {
68 if (component == null) return component; 69 if (component == null) return component;
69 70
70 return component.replaceAll('%3A', ':') 71 return component
71 .replaceAll('%2F', '/') 72 .replaceAll('%3A', ':')
72 .replaceAll('%3F', '?') 73 .replaceAll('%2F', '/')
73 .replaceAll('%3D', '=') 74 .replaceAll('%3F', '?')
74 .replaceAll('%26', '&') 75 .replaceAll('%3D', '=')
75 .replaceAll('%20', ' '); 76 .replaceAll('%26', '&')
77 .replaceAll('%20', ' ');
76 } 78 }
77 } 79 }
OLDNEW
« no previous file with comments | « samples-dev/swarm/swarm_ui_lib/util/StringUtils.dart ('k') | samples-dev/swarm/swarm_ui_lib/view/CompositeView.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698