Index: pkg/http/lib/src/utils.dart |
diff --git a/pkg/http/lib/src/utils.dart b/pkg/http/lib/src/utils.dart |
index 838395984a690af559bddb3d95b506839e6762a3..6a801e194097fd05441b96ba35804b5b1c8a42de 100644 |
--- a/pkg/http/lib/src/utils.dart |
+++ b/pkg/http/lib/src/utils.dart |
@@ -36,32 +36,11 @@ Map<String, String> queryToMap(String queryList, {Encoding encoding}) { |
String mapToQuery(Map<String, String> map, {Encoding encoding}) { |
var pairs = <List<String>>[]; |
map.forEach((key, value) => |
- pairs.add([urlEncode(key, encoding: encoding), |
- urlEncode(value, encoding: encoding)])); |
+ pairs.add([Uri.encodeQueryComponent(key, encoding: encoding), |
+ Uri.encodeQueryComponent(value, encoding: encoding)])); |
return pairs.map((pair) => "${pair[0]}=${pair[1]}").join("&"); |
} |
-// TODO(nweiz): get rid of this when issue 12780 is fixed. |
-/// URL-encodes [source] using [encoding]. |
-String urlEncode(String source, {Encoding encoding}) { |
- if (encoding == null) encoding = UTF8; |
- return encoding.encode(source).map((byte) { |
- // Convert spaces to +, like encodeQueryComponent. |
- if (byte == 0x20) return '+'; |
- // Pass through digits. |
- if ((byte >= 0x30 && byte < 0x3A) || |
- // Pass through uppercase letters. |
- (byte >= 0x41 && byte < 0x5B) || |
- // Pass through lowercase letters. |
- (byte >= 0x61 && byte < 0x7B) || |
- // Pass through `-._~`. |
- (byte == 0x2D || byte == 0x2E || byte == 0x5F || byte == 0x7E)) { |
- return new String.fromCharCode(byte); |
- } |
- return '%' + byte.toRadixString(16).toUpperCase(); |
- }).join(); |
-} |
- |
/// Like [String.split], but only splits on the first occurrence of the pattern. |
/// This will always return an array of two elements or fewer. |
/// |