File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,10 +83,18 @@ const mergeTransformations = (initTransformation1, transformation2) => {
8383// Video-only transformation keys invalid for static images (e.g. poster, sprite)
8484export const VIDEO_ONLY_TRANSFORMATION_KEYS = [ 'streaming_profile' , 'video_codec' ] ;
8585
86+ const filterTxArray = ( arr ) =>
87+ arr . map ( ( t ) => omit ( t , VIDEO_ONLY_TRANSFORMATION_KEYS ) ) . filter ( ( t ) => Object . keys ( t ) . length > 0 ) ;
88+
8689export const omitVideoOnlyTransformations = ( transformation ) => {
8790 if ( ! transformation || typeof transformation !== 'object' ) return transformation ;
8891 if ( Array . isArray ( transformation ) ) {
89- return transformation . map ( ( t ) => omit ( t , VIDEO_ONLY_TRANSFORMATION_KEYS ) ) . filter ( ( t ) => Object . keys ( t ) . length > 0 ) ;
92+ return filterTxArray ( transformation ) ;
93+ }
94+ if ( Array . isArray ( transformation ?. transformation ) ) {
95+ const result = omit ( transformation , VIDEO_ONLY_TRANSFORMATION_KEYS ) ;
96+ result . transformation = filterTxArray ( transformation . transformation ) ;
97+ return result ;
9098 }
9199 return omit ( transformation , VIDEO_ONLY_TRANSFORMATION_KEYS ) ;
92100} ;
You can’t perform that action at this time.
0 commit comments