Fix TypeError regarding matchAll (#579)

Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
ekzyis 2023-10-23 06:03:11 +02:00 committed by GitHub
parent 3160a3f66f
commit d641c305b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -14,7 +14,8 @@ export const isJob = item => typeof item.maxBid !== 'undefined'
const deletePattern = /\B@delete\s+in\s+(\d+)\s+(second|minute|hour|day|week|month|year)s?/gi
export const getDeleteCommand = (text = '') => {
export const getDeleteCommand = (text) => {
if (!text) return false
const matches = [...text.matchAll(deletePattern)]
const commands = matches?.map(match => ({ number: match[1], unit: match[2] }))
return commands.length ? commands[commands.length - 1] : undefined