Skip to content

Commit f9c2053

Browse files
committed
fix(UrlMatcher): query param function defaults
1 parent ed844c6 commit f9c2053

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/urlMatcherFactory.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ UrlMatcher.prototype.exec = function (path, searchParams) {
230230
for (/**/; i < nTotal; i++) {
231231
param = params[i];
232232
cfg = this.params[param];
233-
values[param] = isDefined(searchParams[param]) ? cfg.type.decode(searchParams[param]) : cfg.value;
233+
values[param] = cfg.$value(searchParams[param]);
234234
}
235235

236236
return values;

test/urlMatcherFactorySpec.js

+9
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,15 @@ describe("urlMatcherFactory", function () {
356356
}
357357
});
358358
expect(m.exec('/foo').bar).toBe("Value from bar()");
359+
360+
var m = new UrlMatcher('/foo?bar', {
361+
params: {
362+
bar: function() {
363+
return "Value from bar()";
364+
}
365+
}
366+
});
367+
expect(m.exec('/foo').bar).toBe("Value from bar()");
359368
});
360369

361370
it("should allow injectable functions", inject(function($stateParams) {

0 commit comments

Comments
 (0)