diff options
| -rw-r--r-- | src/Angular.js | 2 | ||||
| -rw-r--r-- | src/ngResource/resource.js | 2 | ||||
| -rw-r--r-- | test/AngularSpec.js | 16 | ||||
| -rw-r--r-- | test/ngResource/resourceSpec.js | 6 |
4 files changed, 20 insertions, 6 deletions
diff --git a/src/Angular.js b/src/Angular.js index 6ea5d1ad..5de57075 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -875,7 +875,7 @@ function encodeUriQuery(val, pctEncodeSpaces) { replace(/%3A/gi, ':'). replace(/%24/g, '$'). replace(/%2C/gi, ','). - replace((pctEncodeSpaces ? null : /%20/g), '+'); + replace(/%20/g, (pctEncodeSpaces ? '%20' : '+')); } diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index 0bcf4cce..ca92e629 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -300,7 +300,7 @@ angular.module('ngResource', ['ng']). replace(/%3A/gi, ':'). replace(/%24/g, '$'). replace(/%2C/gi, ','). - replace((pctEncodeSpaces ? null : /%20/g), '+'); + replace(/%20/g, (pctEncodeSpaces ? '%20' : '+')); } function Route(template, defaults) { diff --git a/test/AngularSpec.js b/test/AngularSpec.js index aed191e7..cc752b6c 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -415,6 +415,14 @@ describe('angular', function() { //encode ' ' as '%20' when a flag is used expect(encodeUriQuery(' ', true)). toEqual('%20%20'); + + //do not encode `null` as '+' when flag is used + expect(encodeUriQuery('null', true)). + toEqual('null'); + + //do not encode `null` with no flag + expect(encodeUriQuery('null')). + toEqual('null'); }); }); @@ -673,7 +681,7 @@ describe('angular', function() { toBe('<ng-abc x="2A">'); }); }); - + describe('startingTag', function() { it('should allow passing in Nodes instead of Elements', function() { var txtNode = document.createTextNode('some text'); @@ -741,11 +749,11 @@ describe('angular', function() { describe('noConflict', function() { var globalAngular; beforeEach(function() { - globalAngular = angular; + globalAngular = angular; }); afterEach(function() { - angular = globalAngular; + angular = globalAngular; }); it('should return angular', function() { @@ -757,7 +765,7 @@ describe('angular', function() { var a = angular.noConflict(); expect(angular).toBeUndefined(); }); - + }); }); diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js index 3f2df284..e5366f4f 100644 --- a/test/ngResource/resourceSpec.js +++ b/test/ngResource/resourceSpec.js @@ -136,6 +136,12 @@ describe("resource", function() { R.get({a: 'doh&foo', bar: ['baz1', 'baz2']}); }); + it('should not encode string "null" to "+" in url params', function() { + var R = $resource('/Path/:a'); + $httpBackend.expect('GET', '/Path/null').respond('{}'); + R.get({a: 'null'}); + }); + it('should allow relative paths in resource url', function () { var R = $resource(':relativePath'); $httpBackend.expect('GET', 'data.json').respond('{}'); |
