@@ -322,9 +322,9 @@ function redirectToS3(r) {
322
322
323
323
if (isDirectoryListing && (r.method === 'GET' || r.method === 'HEAD')) {
324
324
r.internalRedirect("@s3PreListing");
325
- } else if ( PROVIDE_INDEX_PAGE == true ) {
325
+ } else if (PROVIDE_INDEX_PAGE === true) {
326
326
r.internalRedirect("@s3");
327
- } else if ( !ALLOW_LISTING && !PROVIDE_INDEX_PAGE && uriPath == "/" ) {
327
+ } else if (!ALLOW_LISTING && !PROVIDE_INDEX_PAGE && uriPath === "/") {
328
328
r.internalRedirect("@error404");
329
329
} else {
330
330
r.internalRedirect("@s3");
@@ -353,22 +353,20 @@ async function loadContent(r) {
353
353
r.internalRedirect("@s3Directory");
354
354
return;
355
355
}
356
- const url = s3uri(r);
356
+ const uri = s3uri(r);
357
357
let reply = await ngx.fetch(
358
- `http://127.0.0.1:80${url }`
358
+ `http://127.0.0.1:80${uri }`
359
359
);
360
360
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
366
366
r.internalRedirect("@s3Directory");
367
367
} else {
368
368
r.internalRedirect("@error500");
369
369
}
370
-
371
- return;
372
370
}
373
371
374
372
/**
0 commit comments