diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index 006f3d3799a2..055f089023ad 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -387,7 +387,9 @@ angular.module('ngResource', ['ng']). val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam]; if (angular.isDefined(val) && val !== null) { encodedVal = encodeUriSegment(val); - url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), encodedVal + "$1"); + url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), function(match, p1) { + return encodedVal + p1; + }); } else { url = url.replace(new RegExp("(\/?):" + urlParam + "(\\W|$)", "g"), function(match, leadingSlashes, tail) { diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js index b23f0ca42bd7..08c27a0f715b 100644 --- a/test/ngResource/resourceSpec.js +++ b/test/ngResource/resourceSpec.js @@ -178,9 +178,11 @@ describe("resource", function() { $httpBackend.expect('GET', '/Path/foo%231').respond('{}'); $httpBackend.expect('GET', '/Path/doh!@foo?bar=baz%231').respond('{}'); + $httpBackend.expect('GET', '/Path/herp$').respond('{}'); R.get({a: 'foo#1'}); R.get({a: 'doh!@foo', bar: 'baz#1'}); + R.get({a: 'herp$'}); });