Skip to content

Commit 4e2b221

Browse files
author
Caleb Kniffen
committed
The is check on type any will always return true.
Fixes breaking change in 0.2.14 where parameters no longer were allowed to have default values of `0`, `false`, `''`, or `undefined`. Fixes: #1915
1 parent da63b27 commit 4e2b221

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
@@ -623,7 +623,7 @@ function $UrlMatcherFactory() {
623623
any: { // does not encode/decode
624624
encode: angular.identity,
625625
decode: angular.identity,
626-
is: angular.identity,
626+
is: function(){ return true; },
627627
equals: angular.equals,
628628
pattern: /.*/
629629
}

test/stateSpec.js

+9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('state', function () {
2424
DD = { parent: D, params: { x: null, y: null, z: null } },
2525
DDDD = { parent: D, controller: function() {}, template: "hey"},
2626
E = { params: { i: {} } },
27+
F = { params: { a: '', b: false, c: 0, d: undefined, e: -1 }},
2728
H = { data: {propA: 'propA', propB: 'propB'} },
2829
HH = { parent: H },
2930
HHH = {parent: HH, data: {propA: 'overriddenA', propC: 'propC'} },
@@ -47,6 +48,7 @@ describe('state', function () {
4748
.state('DD', DD)
4849
.state('DDDD', DDDD)
4950
.state('E', E)
51+
.state('F', F)
5052
.state('H', H)
5153
.state('HH', HH)
5254
.state('HHH', HHH)
@@ -915,6 +917,7 @@ describe('state', function () {
915917
'DD',
916918
'DDDD',
917919
'E',
920+
'F',
918921
'H',
919922
'HH',
920923
'HHH',
@@ -982,6 +985,12 @@ describe('state', function () {
982985
expect($state.params).toEqual({ x: null, y: null });
983986
}));
984987

988+
it("should allow falsy default values for non-url params", inject(function($state, $q) {
989+
$state.go("F"); $q.flush();
990+
expect($state.current.name).toBe("F");
991+
expect($state.params).toEqual({ a: '', b: false, c: 0, d: undefined, e: -1 });
992+
}));
993+
985994
it("should allow arbitrary objects to pass for non-url params", inject(function($state, $q) {
986995
$state.go("D", { x: 100, y: { foo: 'bar' } }); $q.flush();
987996
expect($state.current.name).toBe("D");

0 commit comments

Comments
 (0)