Improved check for maxDistance, to check if the converted value is NaN

This commit is contained in:
alexandercerutti
2018-09-09 16:03:01 +02:00
parent d9a276026e
commit 4bc46510dc

View File

@@ -256,10 +256,16 @@ class Pass {
} }
if (type === "maxDistance" && (typeof data === "string" || typeof data === "number")) { if (type === "maxDistance" && (typeof data === "string" || typeof data === "number")) {
this.props[type] = Number(data); let conv = Number(data);
// condition to proceed
let cond = isNaN(conv);
if (!cond) {
this.props[type] = conv;
}
return Object.assign({ return Object.assign({
length: 1 length: Number(!cond)
}, this); }, this);
} else if (type === "relevantDate") { } else if (type === "relevantDate") {
let dateParse = dateToW3CString(data); let dateParse = dateToW3CString(data);
@@ -271,7 +277,7 @@ class Pass {
} }
return Object.assign({ return Object.assign({
length: Number(!!convDate) length: Number(!!dateParse)
}, this); }, this);
} }
} }