1
0
Fork 0
mirror of synced 2024-07-29 18:15:49 +12:00

Improving regex for processing custom SVG.

This commit is contained in:
mike12345567 2022-09-30 09:17:38 +01:00
parent 22d501edee
commit c40ce20a38

View file

@ -5,13 +5,13 @@
function substituteSize(svg) {
if (svg.includes("height=")) {
svg = svg.replace(/height="\d*"/, `height="${size}"`)
svg = svg.replace(/height="[^"]+"/, `height="${size}"`)
}
if (svg.includes("width=")) {
svg = svg.replace(/width="\d*"/, `width="${size}"`)
svg = svg.replace(/width="[^"]+"/, `width="${size}"`)
}
if (svg.includes("id=")) {
const matches = svg.match(/id="(.*)"/g)
const matches = svg.match(/id="([^"]+)"/g)
for (let match of matches) {
svg = svg.replace(new RegExp(match, "g"), Helpers.uuid())
}