Skip to content

Commit e769819

Browse files
committed
v1.4.2 - CU-86787rt1x - ClickClock: Corrigir Regex que identifica ID de issue
1 parent 7256a3c commit e769819

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "click-clock",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"private": false,
55
"main": "./out/main/index.js",
66
"scripts": {

src/renderer/src/clickupServices.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,38 @@ export async function getTaskListTime(taskIds: string[], config: { clickupApiKey
9797
}
9898

9999
export function clickupIdFromText(text: string): string | undefined {
100-
return /(?:^|\s)(?:CU-|#)?([a-zA-Z]*\d[a-zA-Z\d]*)(?=\s|$)/g.exec(text)?.[1]
100+
const regexCU = /CU-([a-z]+|\d+)+\b/g
101+
const matchesCU = text.match(regexCU)
102+
103+
if (matchesCU && matchesCU.length > 0) {
104+
return matchesCU[0].replace('CU-', '')
105+
}
106+
107+
const regexSharp = /#([a-z]+|\d+)+\b/g
108+
const matchesSharp = text.match(regexSharp)
109+
110+
if (matchesSharp && matchesSharp.length > 0) {
111+
return matchesSharp[0].replace('#', '')
112+
}
113+
114+
let textRefined = text
115+
let matchesPure
116+
let attempts = 0
117+
do {
118+
const regexPure = /\b([a-z]+|\d+){7,}\b/g
119+
matchesPure = textRefined.match(regexPure)
120+
if (matchesPure && matchesPure.length) {
121+
const foundMatch = matchesPure[0].match(/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{7,}$/g)
122+
if (foundMatch) {
123+
return foundMatch[0]
124+
}
125+
126+
textRefined = textRefined.replace(matchesPure[0], '')
127+
}
128+
attempts++
129+
} while (matchesPure && attempts < 4)
130+
131+
return undefined
101132
}
102133

103134
export function getTaskTimeStatus(taskStatus: TaskStatus | null, statusName: string): number {

0 commit comments

Comments
 (0)