Fix convert to snake case algorithm
subdan opened this issue · comments
Figma's icon name icons / 24 / arrow back
nameValidateRegexp: '^icons _ (\d\d) _ ([A-Za-z0-9 /_-]+)$'
nameReplaceRegexp: 'n2_icon_$2_$1'
Expected result n2_icon_arrow_back_24
Actual result n_2_icon_arrow_back_24
When RegExp replace operation finishes, icon name becomes "n2_icon_arrow back_24"
. Next step is converting the string to snake case. This operation doesn't execute if name already in snake case. Because icon name contains space « » symbol, converting to snake case operation initiated. How converting to snake case works:
- split string to substring. Every number becomes substring.
["n", "2", "icon", "arrow", "back", "24"]
- lowercase each substring
- Join using "_" separator
The result is n_2_icon_arrow_back_24
Need to update convert to snake case algorithm to not to split n2
to two substrings.