Skip to content

Commit e03fd3b

Browse files
committed
Regexp updates for comment parsing
1 parent fbd6561 commit e03fd3b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

components/zendesk/sources/new-ticket-comment-added/new-ticket-comment-added.mjs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,14 @@ export default {
5959
},
6060
convertCommentsToJson(raw) {
6161
return [
62-
...raw.matchAll(/#<Comment (.*?)>/g),
62+
...raw.matchAll(/#<Comment (.*?)(value: "[^"]*")(.*?)>/g),
6363
].map((match) => {
64-
const fields = match[1]
64+
const valueField = match[0].match(/(?<=, )value: "([^"]|\\")*[^\\]",/)?.[0];
65+
const baseMatch = match[0].replace(/^#<Comment /, "");
66+
const baseMatchWithoutValue = valueField
67+
? baseMatch.split(valueField).join("")
68+
: baseMatch;
69+
const fields = baseMatchWithoutValue
6570
.split(",")
6671
.map((part) => part.trim())
6772
.map((pair) => {
@@ -81,7 +86,15 @@ export default {
8186
cleaned,
8287
];
8388
});
84-
return Object.fromEntries(fields);
89+
return Object.fromEntries(valueField
90+
? [
91+
...fields,
92+
[
93+
"value",
94+
valueField?.replace(/^value: ?/, ""),
95+
],
96+
]
97+
: fields);
8598
});
8699
},
87100
isRelevant(payload) {

0 commit comments

Comments
 (0)