diff options
| author | pavelgj | 2013-01-08 14:19:40 -0800 | 
|---|---|---|
| committer | Igor Minar | 2013-01-22 11:32:27 -0800 | 
| commit | 4439e393198d6a1657c02c098e1b13212c3f1db6 (patch) | |
| tree | 412e92f690f792aff6f2168e19e46753cb3296bd /src/ngResource | |
| parent | b49c3a1a1efc85b31053481eea450c7be407957c (diff) | |
| download | angular.js-4439e393198d6a1657c02c098e1b13212c3f1db6.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.js | 9 | 
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index 6dfad572..36b0eff7 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -291,7 +291,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(/\/?#$/, '');  | 
