aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/httpSpec.js
diff options
context:
space:
mode:
authorVojta Jina2013-02-14 14:39:55 -0800
committerVojta Jina2013-02-14 14:52:46 -0800
commit288b69a314e9bd14458b6647532eb62aad5c5cdf (patch)
treeab1b1e4eb441b5340780ff44589c3b8186510142 /test/ng/httpSpec.js
parent2a2123441c2b749b8f316a24c3ca3f77a9132a01 (diff)
downloadangular.js-288b69a314e9bd14458b6647532eb62aad5c5cdf.tar.bz2
fix($http): do not encode special characters `@$:,` in params
encodeURIComponent is too aggressive and doesn't follow http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path segments so we need this test to make sure that we don't over-encode the params and break stuff like buzz api which uses @self. This is has already been fixed in `$resource`. This commit fixes it in a same way for `$http` as well. BREAKING CHANGE: $http does follow RFC3986 and does not encode special characters like `$@,:` in params. If your application needs to encode these characters, encode them manually, before sending the request.
Diffstat (limited to 'test/ng/httpSpec.js')
-rw-r--r--test/ng/httpSpec.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js
index 3b4905f9..600a6a2e 100644
--- a/test/ng/httpSpec.js
+++ b/test/ng/httpSpec.js
@@ -144,7 +144,7 @@ describe('$http', function() {
it('should jsonify objects in params map', inject(function($httpBackend, $http) {
- $httpBackend.expect('GET', '/url?a=1&b=%7B%22c%22%3A3%7D').respond('');
+ $httpBackend.expect('GET', '/url?a=1&b=%7B%22c%22:3%7D').respond('');
$http({url: '/url', params: {a:1, b:{c:3}}, method: 'GET'});
}));
@@ -153,6 +153,17 @@ describe('$http', function() {
$httpBackend.expect('GET', '/url?a=1&a=2&a=3').respond('');
$http({url: '/url', params: {a: [1,2,3]}, method: 'GET'});
}));
+
+
+ it('should not encode @ in url params', function() {
+ //encodeURIComponent is too agressive and doesn't follow http://www.ietf.org/rfc/rfc3986.txt
+ //with regards to the character set (pchar) allowed in path segments
+ //so we need this test to make sure that we don't over-encode the params and break stuff
+ //like buzz api which uses @self
+
+ $httpBackend.expect('GET', '/Path?!do%26h=g%3Da+h&:bar=$baz@1').respond('');
+ $http({url: '/Path', params: {':bar': '$baz@1', '!do&h': 'g=a h'}, method: 'GET'});
+ });
});