@@ -75,8 +75,12 @@ var bodyValidations = flow.series(
7575 ) ,
7676 mw . body ( 'env' ) . require ( )
7777 . then (
78- mw . body ( 'env' ) . array ( )
79- . validate ( validations . isArrayOf ( 'string' ) ) ,
78+ mw . body ( 'env' ) . array ( ) ,
79+ mw . body ( 'env' ) . mapValues ( function ( envArr ) {
80+ return envArr . filter ( function ( val ) {
81+ return ! ( / ^ \s * $ / . test ( val ) ) ;
82+ } ) ;
83+ } ) ,
8084 mw . body ( 'env' ) . each (
8185 function ( env , req , eachReq , res , next ) {
8286 eachReq . env = env ;
@@ -182,22 +186,6 @@ var removeInstanceContainer = // TODO: this has a lot of overlap with instance s
182186 } ) ) ;
183187 } ;
184188
185- /**
186- * Remove any empty/whitespace-only env values
187- * @param {array } req.body.env
188- */
189- var instanceTransformEnvs = flow . series (
190- mw . body ( 'env' ) . require ( )
191- . then (
192- mw . body ( 'env' ) . array ( ) ,
193- mw . body ( 'env' ) . mapValues ( function ( envArr ) {
194- return envArr . filter ( function ( val ) {
195- return ! ( / ^ \s * $ / . test ( val ) ) ;
196- } ) ;
197- } )
198- )
199- ) ;
200-
201189/** Get's the list of instances to be displayed to the user. This should contain all of the
202190 * instances owned by the owner, as well as those owned by groups (s)he is part of
203191 * @event GET rest/instances
@@ -227,7 +215,6 @@ app.get('/instances/',
227215app . post ( '/instances/' ,
228216 mw . body ( 'build' ) . require ( ) . validate ( validations . isObjectId ) ,
229217 mw . body ( 'name' , 'owner' , 'env' , 'parent' , 'build' ) . pick ( ) ,
230- instanceTransformEnvs ,
231218 // validate body types
232219 mw . body ( 'owner.github' ) . require ( )
233220 . then (
@@ -438,7 +425,6 @@ app.patch('/instances/:id',
438425 . then (
439426 mw . body ( ) . unset ( 'build' ) ) ,
440427 mw . body ( { or : [ 'public' , 'name' , 'build' , 'env' ] } ) . require ( ) . pick ( ) ,
441- instanceTransformEnvs ,
442428 bodyValidations ,
443429 mw . body ( { or : [ 'build' , 'name' ] } ) . require ( )
444430 . then (
0 commit comments