From: Benjamin Auder Date: Mon, 2 Dec 2019 15:24:58 +0000 (+0100) Subject: Fix extractTime() function X-Git-Url: https://git.auder.net/variants/Checkered/vendor/css/doc/R.css?a=commitdiff_plain;h=db13014d0aee87402afc2289131d65c401f71bfe;p=vchess.git Fix extractTime() function --- diff --git a/client/src/utils/timeControl.js b/client/src/utils/timeControl.js index 194deaf6..3f5a6506 100644 --- a/client/src/utils/timeControl.js +++ b/client/src/utils/timeControl.js @@ -26,11 +26,11 @@ export function extractTime(timeControl) // Concatenate usual time control suffixes, in case of none is provided tcParts[0] += "m"; tcParts[1] += "s"; - const mainTimeArray = tcParts[0].match(/([0-9]+)([smhd]+)/); + const mainTimeArray = tcParts[0].match(/([0-9]+)([smhd]+)/); if (!mainTimeArray) return null; const mainTimeValue = parseInt(mainTimeArray[1]); - const mainTimeUnit = mainTimeArray[2]; + const mainTimeUnit = mainTimeArray[2][0]; const mainTime = timeUnitToSeconds(mainTimeValue, mainTimeUnit); let increment = 0; if (tcParts.length >= 2) @@ -39,7 +39,7 @@ export function extractTime(timeControl) if (!incrementArray) return null; const incrementValue = parseInt(incrementArray[1]); - const incrementUnit = incrementArray[2]; + const incrementUnit = incrementArray[2][0]; // Increment unit cannot be larger than main unit: if (isLargerUnit(incrementUnit, mainTimeUnit)) return null;