diff options
| author | Igor Minar | 2011-02-16 19:48:21 -0500 |
|---|---|---|
| committer | Igor Minar | 2011-02-17 23:06:53 -0800 |
| commit | 9e30baad3feafc82fb2f2011fd3f21909f4ba29e (patch) | |
| tree | 98bceb6601422c859b1f7cf326fdb77385593808 /test/ResourceSpec.js | |
| parent | a070ff5ad08450a1eb6375790fc90693d624e283 (diff) | |
| download | angular.js-9e30baad3feafc82fb2f2011fd3f21909f4ba29e.tar.bz2 | |
resources should not over-encode chars in url path
- added encodeUriSegment that properly encodes only those chars
that URI RFC requires us to encode
- modified Resource to use encodeUriSegment
Diffstat (limited to 'test/ResourceSpec.js')
| -rw-r--r-- | test/ResourceSpec.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index adc93b92..c93bdafb 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -43,11 +43,22 @@ describe("resource", function() { it('should correctly encode url params', function(){ var R = resource.route('/Path/:a'); xhr.expectGET('/Path/foo%231').respond({}); - xhr.expectGET('/Path/doh!%40foo?bar=baz%231').respond({}); + xhr.expectGET('/Path/doh!@foo?bar=baz%231').respond({}); R.get({a: 'foo#1'}); R.get({a: 'doh!@foo', bar: 'baz#1'}); }); + it('should not encode @ in url params', function() { + //encodeURIComponent is too agressive and doesn't follow http://www.ietf.org/rfc/rfc2396.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 + + var R = resource.route('/Path/:a'); + xhr.expectGET('/Path/doh@foo?bar=baz@1').respond({}); + R.get({a: 'doh@foo', bar: 'baz@1'}); + }) + it("should build resource with default param", function(){ xhr.expectGET('/Order/123/Line/456.visa?minimum=0.05').respond({id:'abc'}); var LineItem = resource.route('/Order/:orderId/Line/:id:verb', {orderId: '123', id: '@id.key', verb:'.visa', minimum:0.05}); |
