Skip to content

Commit aa94ce3

Browse files
fix($urlMatcherFactory): make date type fn check .is before running
Closes #1564
1 parent 750f5cf commit aa94ce3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/urlMatcherFactory.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,9 @@ function $UrlMatcherFactory() {
588588
},
589589
date: {
590590
encode: function (val) {
591-
return [
592-
val.getFullYear(),
591+
if (!this.is(val))
592+
return undefined;
593+
return [ val.getFullYear(),
593594
('0' + (val.getMonth() + 1)).slice(-2),
594595
('0' + val.getDate()).slice(-2)
595596
].join("-");
@@ -600,7 +601,7 @@ function $UrlMatcherFactory() {
600601
return match ? new Date(match[1], match[2] - 1, match[3]) : undefined;
601602
},
602603
is: function(val) { return val instanceof Date && !isNaN(val.valueOf()); },
603-
equals: function (a, b) { return a.toISOString() === b.toISOString(); },
604+
equals: function (a, b) { return this.is(a) && this.is(b) && a.toISOString() === b.toISOString(); },
604605
pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,
605606
capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/
606607
},

0 commit comments

Comments
 (0)