@dicebear/converter
Advanced tools
Comparing version 5.0.0 to 5.0.1
export function ensureSize(svg, defaultSize = 512) { | ||
let size = defaultSize; | ||
svg = svg.replace(/<svg([^>]*?(?:width="(\d+)"[^>]*)?)>/, (match, g1, g2) => { | ||
if (g2) { | ||
size = parseInt(g2); | ||
svg = svg.replace(/<svg([^>]*)/, (match, g1) => { | ||
const found = g1.match(/width="([^"]+)"/); | ||
if (found) { | ||
size = parseInt(found[1]); | ||
} | ||
if (g1.match(/width="([^"]+)"/)) { | ||
g1 = g1.replace(/width="([^"]+)"/, `width="${size}"`); | ||
} | ||
else { | ||
g1 += ` width="${size}" height="${size}"`; | ||
g1 += ` width="${size}"`; | ||
} | ||
return `<svg${g1}>`; | ||
if (g1.match(/height="([^"]+)"/)) { | ||
g1 = g1.replace(/height="([^"]+)"/, `height="${size}"`); | ||
} | ||
else { | ||
g1 += ` height="${size}"`; | ||
} | ||
return `<svg${g1}`; | ||
}); | ||
return { svg, size }; | ||
} |
{ | ||
"name": "@dicebear/converter", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "SVG Converter for DiceBear", | ||
@@ -74,3 +74,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "e8a60b4611b5738c7f46910f77b97ef1967f32dc" | ||
"gitHead": "2853e690ca9908cf78108bad39284c9de15a471e" | ||
} |
546240
242