updated regex to match service by data-service attribute in html anchor tags

This commit is contained in:
dylan 2025-12-31 00:19:02 +00:00
parent 147445df66
commit 7740822918

View file

@ -6,11 +6,11 @@ import sanitizeHtml from 'sanitize-html'
// helper functions
// ========================================================================
// regex to match service name within an html anchor tag
// regex to match service by data-service attribute within an html anchor tag
// used when linkFormat is 'html' in config.js
export function htmlServiceLinkRegex(serviceName) {
return new RegExp(
`(<a[^>]+href=["'][^"']*["'][^>]*>)${serviceName}(<\\/a>)`,
`(<a[^>]*data-service=["']${serviceName}["'][^>]*>)([^<]*)(<\\/a>)`,
'i',
)
}