Sorry, that’s my mistake in the original code.
Just change the contents.match
line to be:
for (const callout of contents.match(new RegExp(regex, 'sg')) || []) {
and that will solve the issue
It’s saying:
“Loop through the items in contents.match
, and if that isn’t an array then loop through this empty array []
.”