From ab4d646157aa2cf689e492d1c713ab7aaeeffcbc Mon Sep 17 00:00:00 2001 From: eonlepapillon Date: Fri, 20 Sep 2013 16:06:28 +0200 Subject: [PATCH] Solved issue 4065 - added ; to the list of replacements - added a unit test --- src/ngResource/resource.js | 1 + test/ngResource/resourceSpec.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index 8f0ac543c744..a197b6994975 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -307,6 +307,7 @@ angular.module('ngResource', ['ng']). function encodeUriSegment(val) { return encodeUriQuery(val, true). replace(/%26/gi, '&'). + replace(/%3B/gi, ';'). replace(/%3D/gi, '='). replace(/%2B/gi, '+'); } diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js index c49ac9e0acfe..10c9b3539cec 100644 --- a/test/ngResource/resourceSpec.js +++ b/test/ngResource/resourceSpec.js @@ -137,6 +137,18 @@ describe("resource", function() { }); + 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 + + var R = $resource('/Path/:a/semicolon'); + $httpBackend.expect('GET', '/Path/a=a;b=b;c=x/semicolon').respond('{}'); + R.get({a: 'a=a;b=b;c=x'}); + }); + + it('should encode array params', function() { var R = $resource('/Path/:a'); $httpBackend.expect('GET', '/Path/doh&foo?bar=baz1&bar=baz2').respond('{}');