mirror of
https://github.com/docker/docs.git
synced 2026-03-27 14:28:47 +07:00
update lambda to handle secure s3 bucket
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -52,5 +52,22 @@ exports.handler = (event, context, callback) => {
|
||||
return
|
||||
}
|
||||
|
||||
// Handle directory requests by appending index.html for requests without file extensions
|
||||
let uri = request.uri;
|
||||
|
||||
// Check if the URI has a dot after the last slash (indicating a filename)
|
||||
// This is more accurate than just checking the end of the URI
|
||||
const hasFileExtension = /\.[^/]*$/.test(uri.split('/').pop());
|
||||
|
||||
// If it's not a file, treat it as a directory and append index.html
|
||||
if (!hasFileExtension) {
|
||||
// Ensure the URI ends with a slash before appending index.html
|
||||
if (!uri.endsWith("/")) {
|
||||
uri += "/";
|
||||
}
|
||||
uri += "index.html";
|
||||
request.uri = uri;
|
||||
}
|
||||
|
||||
callback(null, request);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user