aboutsummaryrefslogtreecommitdiffstats
path: root/src/ngResource
diff options
context:
space:
mode:
authorpavelgj2013-01-08 14:19:40 -0800
committerMisko Hevery2013-01-18 20:52:57 -0800
commitb2f46251aca76c8568ee7d4bab54edbc9d7a186a (patch)
treeb27ab65853cb6b023b9a644cb5b5f20a6cddfa43 /src/ngResource
parenta26234f7183013e2fcc9b35377e181ad96dc9917 (diff)
downloadangular.js-b2f46251aca76c8568ee7d4bab54edbc9d7a186a.tar.bz2
fix(ngResource): correct leading slash removal.
Fixed an issues with ngResource param substitution where it was incorrectly removing leading slash when param was followed by a non-slash character. Ex: '/:foo/:bar.baz/:aux' params = { foo: 'aaa', bar: undefined, aux: undefined } The above params were incorrectly producing '/aaa.baz' but now it results in '/aaa/.baz'.
Diffstat (limited to 'src/ngResource')
-rw-r--r--src/ngResource/resource.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js
index b2bf86cb..7e26a6a4 100644
--- a/src/ngResource/resource.js
+++ b/src/ngResource/resource.js
@@ -311,7 +311,14 @@ angular.module('ngResource', ['ng']).
encodedVal = encodeUriSegment(val);
url = url.replace(new RegExp(":" + urlParam + "(\\W)", "g"), encodedVal + "$1");
} else {
- url = url.replace(new RegExp("/?:" + urlParam + "(\\W)", "g"), '$1');
+ url = url.replace(new RegExp("(\/?):" + urlParam + "(\\W)", "g"), function(match,
+ leadingSlashes, tail) {
+ if (tail.charAt(0) == '/') {
+ return tail;
+ } else {
+ return leadingSlashes + tail;
+ }
+ });
}
});
url = url.replace(/\/?#$/, '');