Chromium Code Reviews| Index: sdk/lib/core/uri.dart |
| diff --git a/sdk/lib/core/uri.dart b/sdk/lib/core/uri.dart |
| index 0eaee85e1011ae740bb4f8951691c085b9a75a80..8303bbe1ed0771228770ef8503ab71d858eea9af 100644 |
| --- a/sdk/lib/core/uri.dart |
| +++ b/sdk/lib/core/uri.dart |
| @@ -769,8 +769,12 @@ class Uri { |
| return _uriDecode(encodedComponent); |
| } |
| - static String decodeQueryComponent(String encodedComponent) { |
| - return _uriDecode(encodedComponent, plusToSpace: true); |
| + static String decodeQueryComponent( |
| + String encodedComponent, |
| + {String decodeString(List<int> bytes): decodeUtf8}) { |
|
Lasse Reichstein Nielsen
2013/07/04 14:56:33
Document the method.
Mention that "decodeString" i
Anders Johnsen
2013/07/05 09:51:28
Done.
|
| + return _uriDecode(encodedComponent, |
| + plusToSpace: true, |
| + decodeString: decodeString); |
| } |
| /** |
| @@ -809,8 +813,13 @@ class Uri { |
| * |
| * Keys in the query string that have no value are mapped to the |
| * empty string. |
| + * |
| + * If [decodeString] is specified, that function will be used to decode the |
|
Lasse Reichstein Nielsen
2013/07/04 14:56:33
again "decodeString" -> decode.
It will be used to
Anders Johnsen
2013/07/05 09:51:28
Done.
|
| + * strings from bytes. Default is a UTF_8 decoder. |
| */ |
| - static Map<String, String> splitQueryString(String query) { |
| + static Map<String, String> splitQueryString( |
| + String query, |
| + {String decodeString(List<int> bytes): decodeUtf8}) { |
| return query.split("&").fold({}, (map, element) { |
| int index = element.indexOf("="); |
| if (index == -1) { |
| @@ -818,7 +827,8 @@ class Uri { |
| } else if (index != 0) { |
| var key = element.substring(0, index); |
| var value = element.substring(index + 1); |
| - map[Uri.decodeQueryComponent(key)] = decodeQueryComponent(value); |
| + map[Uri.decodeQueryComponent(key, decodeString: decodeString)] = |
| + decodeQueryComponent(value, decodeString: decodeString); |
| } |
| return map; |
| }); |
| @@ -904,7 +914,9 @@ class Uri { |
| * A JavaScript-like decodeURI function. It unescapes the string [text] and |
|
Lasse Reichstein Nielsen
2013/07/04 14:56:33
This methods needs a new documentation (a standalo
Bill Hesse
2013/07/05 08:52:13
I would make clear that it decodes URI encoding to
Anders Johnsen
2013/07/05 09:51:28
Done.
Anders Johnsen
2013/07/05 09:51:28
Done.
|
| * returns the unescaped string. |
| */ |
| - static String _uriDecode(String text, {bool plusToSpace: false}) { |
| + static String _uriDecode(String text, |
| + {bool plusToSpace: false, |
| + String decodeString(List<int> bytes): decodeUtf8}) { |
| StringBuffer result = new StringBuffer(); |
| List<int> codepoints = new List<int>(); |
| for (int i = 0; i < text.length;) { |
| @@ -927,7 +939,7 @@ class Uri { |
| if (i == text.length) break; |
| ch = text.codeUnitAt(i); |
| } |
| - result.write(decodeUtf8(codepoints)); |
| + result.write(decodeString(codepoints)); |
| } |
| } |
| return result.toString(); |