From 51449360f51e9c6aa87979667fd4d21f8e162d68 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Thu, 30 Nov 2023 06:38:27 -0800 Subject: [PATCH] fix(cleanupIds): properly handle begin regex to fix #1775 (#1862) --- plugins/cleanupIds.js | 2 +- test/plugins/cleanupIds.24.svg | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/plugins/cleanupIds.24.svg diff --git a/plugins/cleanupIds.js b/plugins/cleanupIds.js index c113db283..671a85248 100644 --- a/plugins/cleanupIds.js +++ b/plugins/cleanupIds.js @@ -13,7 +13,7 @@ exports.description = 'removes unused IDs and minifies used'; const regReferencesUrl = /\burl\((["'])?#(.+?)\1\)/g; const regReferencesHref = /^#(.+?)$/; -const regReferencesBegin = /(\D+)\./; +const regReferencesBegin = /(\w+)\.[a-zA-Z]/; const generateIdChars = [ 'a', 'b', diff --git a/test/plugins/cleanupIds.24.svg b/test/plugins/cleanupIds.24.svg new file mode 100644 index 000000000..26de623c1 --- /dev/null +++ b/test/plugins/cleanupIds.24.svg @@ -0,0 +1,24 @@ +Properly rename IDs, by matching them properly (exclude semicolons, include numbers) +See https://github.com/svg/svgo/issues/1775 + +=== + + + + + + + + + + +@@@ + + + + + + + + + \ No newline at end of file