ionic-team / ionicons

Premium hand-crafted icons built by Ionic, for Ionic apps and web apps everywhere 🌎
http://ionicons.com
MIT License
17.39k stars 2.06k forks source link

bug: Kebab case does not handle numbers properly #1338

Closed MasonVX closed 2 months ago

MasonVX commented 2 months ago

Current Behavior

At the moments icons I add with AddIcons which have numbers included convert those the following way eg.:

"testArrowLeft2" -> "test-arrow-left2"

This is a problem for me when to convert to standalone components in angular. A library uses an icon which has a number at the end and the icon is hardcoded into the library as eg. "test-arrow-left-2".

Expected Behavior

Expected would be "test-arrow-left-2"

Steps to Reproduce

Use an icon with a number at the end.

Code Reproduction URL

No response

Additional Information

The problem seams to be in the used regex: const toKebabCase = name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();

possible solution would be:

image

Here not as an image: /([a-z]|(?=[A-Z]))([A-Z0-9])/g

MasonVX commented 2 months ago

ps. I had time and added a pull request for this issue: https://github.com/ionic-team/ionicons/pull/1339