From cc4030f4e4905ab7a74bebee204a4990481bd8e9 Mon Sep 17 00:00:00 2001 From: Forketyfork Date: Fri, 23 May 2025 17:54:33 +0200 Subject: [PATCH] Improvements to the template parsing code --- main.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/main.ts b/main.ts index ca2904c..f9eddcd 100644 --- a/main.ts +++ b/main.ts @@ -135,22 +135,17 @@ export default class YouTrackPlugin extends Plugin { // Parse list of fields referenced in a template parseFieldListFromTemplate(template: string): string[] { const fields = new Set(); - const regex = /\$\{([^}]+)\}/g; - let match: RegExpExecArray | null; - while ((match = regex.exec(template)) !== null) { + const matches = template.matchAll(/\$\{([^}]+)\}/g); + + for (const match of matches) { const field = match[1].trim(); - if (!field || field === "id" || field === "url") { - continue; - } - if (field === "title") { - fields.add("summary"); - } else { - fields.add(field); - } + if (!field || field === "id" || field === "url") continue; + + fields.add(field === "title" ? "summary" : field); } + return Array.from(fields); } - formatTimestamp(value: unknown): string { const date = typeof value === "number" ? new Date(value) : new Date(String(value)); if (isNaN(date.getTime())) {