mirror of
https://github.com/forketyfork/obsidian-youtrack-fetcher.git
synced 2026-07-22 12:30:26 +00:00
Improvements to the template parsing code
This commit is contained in:
parent
d87aafbadf
commit
cc4030f4e4
1 changed files with 7 additions and 12 deletions
19
main.ts
19
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<string>();
|
||||
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())) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue