From 4909d1d39d61d6945a0820a5a7276c1e657ba262 Mon Sep 17 00:00:00 2001 From: Benjamín Eidelman Date: Mon, 20 Aug 2012 19:47:26 -0300 Subject: fix($resource): allow falsy values in URL parameters Close #1212 when a param value was 0 (or false) it was ignored and removed from url. after this fix that only happens if the value is undefined or null. --- src/ngResource/resource.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ngResource/resource.js') diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index cd03d2d2..0a40cedd 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -285,7 +285,8 @@ angular.module('ngResource', ['ng']). params = params || {}; forEach(this.urlParams, function(_, urlParam){ - if (val = (params[urlParam] || self.defaults[urlParam])) { + val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam]; + if (isDefined(val) && val !== null) { encodedVal = encodeUriSegment(val); url = url.replace(new RegExp(":" + urlParam + "(\\W)", "g"), encodedVal + "$1"); } else { -- cgit v1.2.3