Created by: nvh95
Fix #10513
If we import an SVG which filename contains some characters like @
, react-scripts test
will fail. For example logo@2x.svg
. The reason is when packages/react-scripts/config/jest/fileTransform.js
transforms logo@2x.svg
to a component with the name of SvgLogo@2X
. It is not a valid component name (or javascript variable).
I fix this by converting a character which is non-letter, non-number, non-underscore, into an ASCII number.
So logo@2x.svg
will be transformed to SVGLogo642X
instead of SvgLogo@2X
, which is a valid component name