Chromium Code Reviews| Index: sdk/lib/core/uri.dart |
| diff --git a/sdk/lib/core/uri.dart b/sdk/lib/core/uri.dart |
| index 10aa827cb190c6e93a8889cad67312629145d5f5..6955f5ccba6c3f2e1b3a6b2d2af9fada12f70ec9 100644 |
| --- a/sdk/lib/core/uri.dart |
| +++ b/sdk/lib/core/uri.dart |
| @@ -2251,6 +2251,10 @@ class Uri { |
| static const int _LOWER_CASE_Z = 0x7A; |
| static const int _BAR = 0x7C; |
| + // Matches a String that _uriEncodes to itself regardless of the kind of |
| + // component. This corresponds to [_unreservedTable]. |
| + static final RegExp _needsNoEncoding = new RegExp(r'^[\-\.0-9A-Z_a-z~]*$'); |
|
Ivan Posva
2015/11/04 05:11:50
Please refrain from using RegExp in core library c
|
| + |
| /** |
| * This is the internal implementation of JavaScript's encodeURI function. |
| * It encodes all characters in the string [text] except for those |
| @@ -2260,6 +2264,8 @@ class Uri { |
| String text, |
| {Encoding encoding: UTF8, |
| bool spaceToPlus: false}) { |
| + if (_needsNoEncoding.hasMatch(text)) return text; |
|
Lasse Reichstein Nielsen
2015/11/03 07:08:19
This should be a regexp that matches canonicalTabl
Lasse Reichstein Nielsen
2015/11/03 07:12:08
Ah, finally realized that the only characters used
Lasse Reichstein Nielsen
2015/11/04 08:32:41
Only do this if encoding is UTF8, LATIN1 or ASCII
|
| + |
| byteToHex(byte, buffer) { |
| const String hex = '0123456789ABCDEF'; |
| buffer.writeCharCode(hex.codeUnitAt(byte >> 4)); |