From 78f9ae1c122a94b81742963be16a1a6856c82e5c Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 6 Jan 2023 14:43:22 +0200 Subject: [PATCH] fix(utils): do not assume that attributes are separated with spaces in loader --- packages/utils/src/loader/utils.ts | 15 ++++++++------- packages/utils/tests/file-system-icon-test.ts | 2 +- packages/utils/tests/fixtures/circle.svg | 7 ++++++- packages/utils/tests/get-custom-icon-test.ts | 2 +- packages/utils/tests/load-icon-test.ts | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/utils/src/loader/utils.ts b/packages/utils/src/loader/utils.ts index 3cb1c47..7a42194 100644 --- a/packages/utils/src/loader/utils.ts +++ b/packages/utils/src/loader/utils.ts @@ -3,6 +3,7 @@ import type { IconifyLoaderOptions } from './types'; const svgWidthRegex = /width\s*=\s*["'](\w+)["']/; const svgHeightRegex = /height\s*=\s*["'](\w+)["']/; +const svgTagRegex = / p != null); if (propsToAdd.length) { - svg = svg.replace(' { test('FileSystemIconLoader with transform', async () => { const result = await FileSystemIconLoader(fixturesDir, (icon) => { - return icon.replace(' -1).toBeTruthy(); expect(result && result.indexOf('height="1em"') > -1).toBeTruthy(); diff --git a/packages/utils/tests/fixtures/circle.svg b/packages/utils/tests/fixtures/circle.svg index e4e7959..991f43b 100644 --- a/packages/utils/tests/fixtures/circle.svg +++ b/packages/utils/tests/fixtures/circle.svg @@ -1 +1,6 @@ - + + + diff --git a/packages/utils/tests/get-custom-icon-test.ts b/packages/utils/tests/get-custom-icon-test.ts index 697a1bb..8e4a686 100644 --- a/packages/utils/tests/get-custom-icon-test.ts +++ b/packages/utils/tests/get-custom-icon-test.ts @@ -61,7 +61,7 @@ describe('Testing getCustomIcon', () => { }, transform(svg) { return svg.replace( - ' { customizations: { transform(svg) { return svg.replace( - '