jhamlet / svg-react-loader

Webpack SVG to React Component Loader
MIT License
559 stars 82 forks source link

Whitespace in filename bug #72

Closed catamphetamine closed 7 years ago

catamphetamine commented 7 years ago
import Person_add_icon from '../../../../assets/images/icons/person add.svg'

Is converted into

function Person add (props) {

You should replace all whitespace string.replace(/\s/g, ''). And what if the filename starts, say, with a digit. Or contains a dot. You should just leave it as SVG.

jhamlet commented 7 years ago

I think just defaulting to 'SvgReactComponent' and only overriding it when a 'name' parameter is given is the best way to go.

jessy1092 commented 7 years ago

I think #71 would fix this issue. It could pass titleCaseDelim: /[\s]/ to handle witespace.

jhamlet commented 7 years ago

Fixed by #71

catamphetamine commented 7 years ago

Version 0.4.4, still the same error.

jhamlet commented 7 years ago

@halt-hammerzeit Are you using the new titleCaseDelim parameter to specify your own delimiter (eg.: /\s+/g)?

catamphetamine commented 7 years ago

@jhamlet Oh, a parameter has to be customized. Ok, thx for the tip. Still my opinion is the same: it should have included whitespace in titleCaseDelim by default.

jhamlet commented 7 years ago

@halt-hammerzeit Still thinking of changing to defaulting to SVGReactComponent if there is no name parameter given. This way I can forgo having to parse the fifteen million ways people want to name their files.

Another option is to allow for a function as the name parameter that receives the filename, and then individuals can customize if they really want to.