Skip to content

Commit

Permalink
fix($urlMatcherFactory): make date type fn check .is before running
Browse files Browse the repository at this point in the history
Closes #1564
  • Loading branch information
christopherthielen committed Nov 21, 2014
1 parent 750f5cf commit aa94ce3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/urlMatcherFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,9 @@ function $UrlMatcherFactory() {
},
date: {
encode: function (val) {
return [
val.getFullYear(),
if (!this.is(val))
return undefined;
return [ val.getFullYear(),
('0' + (val.getMonth() + 1)).slice(-2),
('0' + val.getDate()).slice(-2)
].join("-");
Expand All @@ -600,7 +601,7 @@ function $UrlMatcherFactory() {
return match ? new Date(match[1], match[2] - 1, match[3]) : undefined;
},
is: function(val) { return val instanceof Date && !isNaN(val.valueOf()); },
equals: function (a, b) { return a.toISOString() === b.toISOString(); },
equals: function (a, b) { return this.is(a) && this.is(b) && a.toISOString() === b.toISOString(); },
pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,
capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/
},
Expand Down

0 comments on commit aa94ce3

Please sign in to comment.