From 9b7fac3e0ae311fe64bb32f959ee8515aa64c0ed Mon Sep 17 00:00:00 2001 From: manubo Date: Mon, 30 Sep 2019 17:13:11 +0200 Subject: [PATCH] Parse empty string (TimeInputParser) --- src/js/utils/TimeInputParser.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/js/utils/TimeInputParser.js b/src/js/utils/TimeInputParser.js index 9be08ee..edb9059 100644 --- a/src/js/utils/TimeInputParser.js +++ b/src/js/utils/TimeInputParser.js @@ -2,11 +2,13 @@ export default class TimeInputParser { #input constructor(input) { - this.#input = input.toLowerCase().replace(/[\s()]/g, "") + this.#input = (input ?? "").toLowerCase().replace(/[\s()]/g, "") } parseSeconds() { - if (this.#isDecimal()) { + if (this.#input === "") { + return 0 + } else if (this.#isDecimal()) { return Math.round(parseFloat(this.#parseDecimal()) * 3600) } else if (this.#isTime()) { return this.#parseTimeAsSeconds()