File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -596,8 +596,21 @@ export default class Stack {
596596 */
597597
598598 sync ( params , fetchOptions ) {
599+ if ( params && typeof params !== "object" ) {
600+ throw new Error ( "Invalid parameters: params must be an object." ) ;
601+ }
599602 this . _query = { } ;
600- this . _query = Utils . mergeDeep ( this . _query , params ) ;
603+
604+ if ( params ) {
605+ for ( const key in params ) {
606+ if ( params . hasOwnProperty ( key ) ) {
607+ if ( typeof params [ key ] !== "string" && typeof params [ key ] !== "number" ) {
608+ throw new Error ( `Invalid parameter value for key "${ key } ": must be a string or number.` ) ;
609+ }
610+ this . _query [ key ] = params [ key ] ;
611+ }
612+ }
613+ }
601614 this . requestParams = {
602615 method : 'POST' ,
603616 headers : Utils . mergeDeep ( { } , this . headers ) ,
@@ -630,7 +643,9 @@ export default class Stack {
630643 if ( url && typeof url === "string" && typeof params === "object" && params . length === undefined ) {
631644 let queryParams = [ ] ;
632645 for ( const operation in params ) {
633- queryParams . push ( operation + '=' + params [ operation ] ) ;
646+ const encodedKey = encodeURIComponent ( operation ) ;
647+ const encodedValue = encodeURIComponent ( params [ operation ] ) ;
648+ queryParams . push ( encodedKey + '=' + encodedValue ) ;
634649 }
635650 url += ( url . indexOf ( "?" ) <= - 1 ) ? "?" + queryParams . join ( '&' ) : "&" + queryParams . join ( '&' ) ;
636651 }
You can’t perform that action at this time.
0 commit comments