Skip to content

Commit

Permalink
feat: Enabled uriEndsWithSlash check into cloudfront-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mamu0 committed Jan 10, 2025
1 parent 2f2d9a6 commit 513b44a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/cloudfront-functions/src/viewer-request-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ const handler = (
// do the rewrite
const { request } = event;
const uri = request.uri;
const uriEndsWithSlash = uri.endsWith('/');

if (uriEndsWithSlash) {
request.uri = uri.replace(/\/$/, '');
}

// Add the .html extension if missing
if (!uri.endsWith('/') && !/\.[0-9a-zA-Z]+$/.test(uri)) {
if (!/\.[0-9a-zA-Z]+$/.test(uri)) {
request.uri += '.html';
}

Expand Down

0 comments on commit 513b44a

Please sign in to comment.