Skip to content

Commit

Permalink
fix: fix escape map and share it across function calls (#457)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam DeHaven <[email protected]>
  • Loading branch information
Justineo and adamdehaven authored Dec 9, 2024
1 parent 07acf4c commit b1cd030
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/__template__/ComponentTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,15 @@ const prefixSvgIdsInString = (svgString: string): string => {
return processedSvgString
}
const htmlEntities: { [key: string]: string } = {
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'&': '&amp;',
}
const escapeHtml = (str: string) => {
const htmlEntities: { [key: string]: string } = {
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;',
'`': '&#039;',
}
return str.replace(/[<>"'`]/g, (match) => htmlEntities[match])
return str.replace(/[<>"'&]/g, (match) => htmlEntities[match])
}
// The `svgOriginalContent` template string will be replaced with the SVG innerHTML in the generate script.
Expand Down

0 comments on commit b1cd030

Please sign in to comment.