Spaces:
Running
Running
File size: 575 Bytes
ecdd7f6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | function generateRandomId(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
}
// From https://blog.jim-nielsen.com/2022/multiple-inline-svgs/
function uniqueSvg(svg) {
const id = generateRandomId(10);
return svg
.replace(/id="clip/g, `id="${id}__clip`)
.replace(/clip-path="url\(#clip/g, `clip-path="url(#${id}__clip`);
}
module.exports = {
uniqueSvg,
};
|