mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 07:14:44 +00:00
fix($resource): null default param results in TypeError
Fixes issue when setting a default param as `null` error `TypeError: Cannot read property 'charAt' of null`
This commit is contained in:
parent
f9b897de4b
commit
cefbcd470d
2 changed files with 11 additions and 1 deletions
|
|
@ -392,7 +392,7 @@ angular.module('ngResource', ['ng']).
|
||||||
actionParams = extend({}, paramDefaults, actionParams);
|
actionParams = extend({}, paramDefaults, actionParams);
|
||||||
forEach(actionParams, function(value, key){
|
forEach(actionParams, function(value, key){
|
||||||
if (isFunction(value)) { value = value(); }
|
if (isFunction(value)) { value = value(); }
|
||||||
ids[key] = value.charAt && value.charAt(0) == '@' ? getter(data, value.substr(1)) : value;
|
ids[key] = value && value.charAt && value.charAt(0) == '@' ? getter(data, value.substr(1)) : value;
|
||||||
});
|
});
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,16 @@ describe("resource", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should not throw TypeError on null default params', function() {
|
||||||
|
$httpBackend.expect('GET', '/Path?').respond('{}');
|
||||||
|
var R = $resource('/Path', {param: null}, {get: {method: 'GET'}});
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
R.get({});
|
||||||
|
}).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should handle multiple params with same name', function() {
|
it('should handle multiple params with same name', function() {
|
||||||
var R = $resource('/:id/:id');
|
var R = $resource('/:id/:id');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue