Skip to content

Commit de6d230

Browse files
authored
Merge pull request #23542 from crazy-max/update-lambda
update lambda to handle secure s3 bucket
2 parents 52e93b0 + f77e196 commit de6d230

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

hack/releaser/cloudfront-lambda-redirects.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,22 @@ exports.handler = (event, context, callback) => {
5252
return
5353
}
5454

55+
// Handle directory requests by appending index.html for requests without file extensions
56+
let uri = request.uri;
57+
58+
// Check if the URI has a dot after the last slash (indicating a filename)
59+
// This is more accurate than just checking the end of the URI
60+
const hasFileExtension = /\.[^/]*$/.test(uri.split('/').pop());
61+
62+
// If it's not a file, treat it as a directory and append index.html
63+
if (!hasFileExtension) {
64+
// Ensure the URI ends with a slash before appending index.html
65+
if (!uri.endsWith("/")) {
66+
uri += "/";
67+
}
68+
uri += "index.html";
69+
request.uri = uri;
70+
}
71+
5572
callback(null, request);
5673
};

0 commit comments

Comments
 (0)