@@ -322,9 +322,9 @@ function redirectToS3(r) {
322322
323323 if ( isDirectoryListing && ( r . method === 'GET' || r . method === 'HEAD' ) ) {
324324 r . internalRedirect ( "@s3PreListing" ) ;
325- } else if ( PROVIDE_INDEX_PAGE == true ) {
325+ } else if ( PROVIDE_INDEX_PAGE === true ) {
326326 r . internalRedirect ( "@s3" ) ;
327- } else if ( ! ALLOW_LISTING && ! PROVIDE_INDEX_PAGE && uriPath == "/" ) {
327+ } else if ( ! ALLOW_LISTING && ! PROVIDE_INDEX_PAGE && uriPath === "/" ) {
328328 r . internalRedirect ( "@error404" ) ;
329329 } else {
330330 r . internalRedirect ( "@s3" ) ;
@@ -353,22 +353,20 @@ async function loadContent(r) {
353353 r . internalRedirect ( "@s3Directory" ) ;
354354 return ;
355355 }
356- const url = s3uri ( r ) ;
356+ const uri = s3uri ( r ) ;
357357 let reply = await ngx . fetch (
358- `http://127.0.0.1:80${ url } `
358+ `http://127.0.0.1:80${ uri } `
359359 ) ;
360360
361- if ( reply . status == 200 ) {
362- // found index.html, so redirect to it
363- r . internalRedirect ( r . variables . request_uri + INDEX_PAGE ) ;
364- } else if ( reply . status == 404 ) {
365- // else just list the contents of the directory
361+ if ( reply . status === 200 ) {
362+ utils . debug_log ( r , `Found index file, redirecting to: ${ uri } ` ) ;
363+ r . internalRedirect ( uri ) ;
364+ } else if ( reply . status === 404 ) {
365+ // As there was no index file found, just list the contents of the directory
366366 r . internalRedirect ( "@s3Directory" ) ;
367367 } else {
368368 r . internalRedirect ( "@error500" ) ;
369369 }
370-
371- return ;
372370}
373371
374372/**
0 commit comments