From f4fc1d34d4e8c00be0d3d22455fd577666d381e1 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Thu, 28 Sep 2023 12:05:22 +0530 Subject: [PATCH] SDA-4300 - Fix timer GitHub action issue --- src/common/utils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/utils.ts b/src/common/utils.ts index 1f4341578..157cf5092 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -1,6 +1,7 @@ // regex match the semver (semantic version) this checks for the pattern X.Y.Z // ex-valid v1.2.0, 1.2.0, 2.3.4-r51 -const semver = /^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?)?)?$/i; +const semver = + /^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?)?)?$/i; const patch = /-([0-9A-Za-z-.]+)/; /** @@ -213,7 +214,9 @@ export const throttle = ( func.apply(null, args); lastRan = Date.now(); } else { - clearTimeout(timer); + if (timer) { + clearTimeout(timer); + } timer = setTimeout(() => { if (Date.now() - lastRan >= wait) { func.apply(null, args);