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:
parent
7fb8bd2c57
commit
0960538526
@ -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('>');
|
||||
|
@ -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()
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user