File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,13 @@ function getFilePath(state) {
9797}
9898
9999function getPlugins ( config ) {
100- return config && Array . isArray ( config . plugins ) ? config . plugins : [ ]
100+ if ( ! config || ! config . plugins ) {
101+ return [ ]
102+ }
103+ if ( ! Array . isArray ( config . plugins ) ) {
104+ throw Error ( "`svgoConfig.plugins` must be an array" )
105+ }
106+ return config . plugins
101107}
102108
103109function extendPlugins ( ...configs ) {
Original file line number Diff line number Diff line change @@ -38,6 +38,20 @@ describe('svgo', () => {
3838 expect ( result ) . toMatchSnapshot ( )
3939 } )
4040
41+ it ( 'should throw error for invalid config.svgoConfig' , ( ) => {
42+ const svgoOptions = [
43+ baseSvg ,
44+ {
45+ svgo : true ,
46+ runtimeConfig : true ,
47+ svgoConfig : { plugins : { removeDesc : false } } ,
48+ } ,
49+ { } ,
50+ ]
51+
52+ expect ( ( ) => svgo ( ...svgoOptions ) ) . toThrow ( )
53+ } )
54+
4155 it ( 'should support icon with config.svgoConfig plugins' , ( ) => {
4256 const result = svgo (
4357 baseSvg ,
You can’t perform that action at this time.
0 commit comments