2
0
mirror of https://github.com/iconify/iconify.git synced 2024-09-19 00:39:02 +00:00

chore: improve svg trim and prettify functions

This commit is contained in:
Vjacheslav Trushkin 2023-12-28 10:24:59 +02:00
parent 7fb8bd2c57
commit 0960538526
4 changed files with 8 additions and 3 deletions

View File

@ -14,6 +14,9 @@ export function prettifySVG(
let result = '';
let level = 0;
// Add space for self closing tags
content = content.replace(/(\s)*\/>/g, ' />');
while (content.length > 0) {
const openIndex = content.indexOf('<');
let closeIndex = content.indexOf('>');

View File

@ -13,6 +13,8 @@ export function trimSVG(str: string): string {
// Trim attribute values
.replace(/\s+"/g, '"')
.replace(/="\s+/g, '="')
// Self closing tags
.replace(/(\s)+\/>/g, '/>')
// Trim it
.trim()
);