svg-sprite / svg-sprite

SVG sprites & stacks galore — A low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites of several types along with suitable stylesheet resources (e.g. CSS, Sass, LESS, Stylus, etc.)

Home Page:https://github.com/svg-sprite/svg-sprite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

passing null for name to add function causes TypeError

theycallmecoach opened this issue · comments

/app/node_modules/svg-sprite/lib/svg-sprite.js:93
             name = trimStart(name.trim(), `${path.sep}.`) || path.basename(file);
                                   ^
 
 TypeError: Cannot read properties of null (reading 'trim')

Found when updating from older 2.0.2 version. My code was incorrectly passing null but it didn't crash ... latest version crash. I've since fixed my code but thought i should let you know the null check needs adjusting...

Thank for the issue. This is the same as #598 (comment)

@strager @Kreeg we are better off refactoring the code to check for null too and maybe drop the default params if they are not needed.

Proposed fix in #817.

commented

Fixed in #824