@@ -265,11 +265,12 @@ function _s3DirQueryParams(uriPath, method) {
265265 return '' ;
266266 }
267267
268- var path = 'delimiter=%2F'
268+ let path = 'delimiter=%2F'
269269
270270 if ( uriPath !== '/' ) {
271- var without_leading_slash = uriPath . charAt ( 0 ) === '/' ?
272- uriPath . substring ( 1 , uriPath . length ) : uriPath ;
271+ let decodedUriPath = decodeURIComponent ( uriPath ) ;
272+ let without_leading_slash = decodedUriPath . charAt ( 0 ) === '/' ?
273+ decodedUriPath . substring ( 1 , decodedUriPath . length ) : decodedUriPath ;
273274 path += '&prefix=' + encodeURIComponent ( without_leading_slash ) ;
274275 }
275276
@@ -329,7 +330,7 @@ function signatureV2(r, bucket, credentials) {
329330
330331 var s3signature = hmac . update ( stringToSign ) . digest ( 'base64' ) ;
331332
332- return ' AWS ' + credentials . accessKeyId + ':' + s3signature ;
333+ return ` AWS ${ credentials . accessKeyId } : ${ s3signature } ` ;
333334}
334335
335336/**
@@ -595,7 +596,9 @@ function _eightDigitDate(timestamp) {
595596 var month = timestamp . getUTCMonth ( ) + 1 ;
596597 var day = timestamp . getUTCDate ( ) ;
597598
598- return '' . concat ( _padWithLeadingZeros ( year , 4 ) , _padWithLeadingZeros ( month , 2 ) , _padWithLeadingZeros ( day , 2 ) ) ;
599+ return '' . concat ( _padWithLeadingZeros ( year , 4 ) ,
600+ _padWithLeadingZeros ( month , 2 ) ,
601+ _padWithLeadingZeros ( day , 2 ) ) ;
599602}
600603
601604/**
@@ -643,9 +646,11 @@ function _padWithLeadingZeros(num, size) {
643646 * @private
644647 */
645648function _escapeURIPath ( uri ) {
646- var components = [ ] ;
649+ // Check to see if the URI path was already encoded. If so, we decode it.
650+ let decodedUri = ( uri . indexOf ( '%' ) >= 0 ) ? decodeURIComponent ( uri ) : uri ;
651+ let components = [ ] ;
647652
648- uri . split ( '/' ) . forEach ( function ( item , i ) {
653+ decodedUri . split ( '/' ) . forEach ( function ( item , i ) {
649654 components [ i ] = encodeURIComponent ( item ) ;
650655 } ) ;
651656
0 commit comments