@@ -95,7 +95,7 @@ export class HttpTransport {
9595 const requestData : RequestData = {
9696 method : method . toUpperCase ( ) ,
9797 url,
98- path : path + ( options ?. params ? `? ${ new URLSearchParams ( options . params as Record < string , string > ) . toString ( ) } ` : '' ) ,
98+ path : this . buildSigningPath ( path , options ?. params ) ,
9999 body,
100100 } ;
101101
@@ -113,6 +113,20 @@ export class HttpTransport {
113113 return { url, init, body } ;
114114 }
115115
116+ private buildSigningPath ( path : string , params ?: Record < string , any > ) : string {
117+ if ( ! params || Object . keys ( params ) . length === 0 ) {
118+ return path ;
119+ }
120+ const searchParams = new URLSearchParams ( ) ;
121+ for ( const [ key , value ] of Object . entries ( params ) ) {
122+ if ( value !== undefined && value !== null ) {
123+ searchParams . append ( key , String ( value ) ) ;
124+ }
125+ }
126+ const qs = searchParams . toString ( ) ;
127+ return qs ? `${ path } ?${ qs } ` : path ;
128+ }
129+
116130 private shouldRetry ( method : string , statusCode : number ) : boolean {
117131 if ( ! this . retry . methods . includes ( method . toUpperCase ( ) ) ) {
118132 return false ;
@@ -128,7 +142,8 @@ export class HttpTransport {
128142 }
129143 return 0 ;
130144 }
131- return this . retry . backoffFactor * Math . pow ( 2 , Math . max ( attempt - 1 , 0 ) ) * 1000 ;
145+ const base = this . retry . backoffFactor * Math . pow ( 2 , Math . max ( attempt - 1 , 0 ) ) * 1000 ;
146+ return base * ( 0.5 + Math . random ( ) * 0.5 ) ;
132147 }
133148
134149 private async maybeDecodeResponse ( response : Response , parseJson : boolean ) : Promise < any > {
0 commit comments