Closed
Description
I'm seeing an error generated in urlMatcherFactory.js by the code that sets a default value.
This occurs when you have an optional param and a default value of null.
function $value(value) {
function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }
function $replace(value) {
var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });
return replacement.length ? replacement[0] : value;
}
value = $replace(value);
return isDefined(value) ? self.type.decode(value) : $$getDefaultValue();
}
The problem occurs in the hasReplaceVal closure, when obj is null/undefined, obj.from causes the error. 'value' is checked if it is defined until after the call to $replace.
I was using this state config:
url: '/site/{siteId:int}?{startDate:date}&{endDate:date}',
params: {
endDate: {
value: null
}
},
I also tried using the string type instead of the date type and the same result occurred.
Changing the default value to an empty string instead of null, allowed it to work, as obj.to would then return undefined instead of causing an error.
Metadata
Metadata
Assignees
Labels
No labels