Skip to content

Commit

Permalink
fix: eslint cloudfront functions
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-calabrese committed Oct 29, 2024
1 parent 8e64458 commit d5e50e2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/cloudfront-functions/src/viewer-request-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@ const handler = (
const isHomepage = uri === '/';

// List of special cases (add more as needed)
const specialCases: string[] = ['.bollo'];
const specialCases: readonly string[] = ['.bollo'];

// Function to check if URI ends with any of the special cases
const isSpecialCase = specialCases.some(caseExt => uri.endsWith(caseExt));
const isSpecialCase = specialCases.some((caseExt) => uri.endsWith(caseExt));

if (!isHomepage) {
if (uriEndsWithSlash) {
request.uri = uri.replace(/\/$/, '');
}
// Always add .html if there's no file extension, including special cases
if (!isGitbookAssets && !isWoff2 && (!/\.[a-zA-Z]+$/.test(uri) || isSpecialCase)) {
if (
!isGitbookAssets &&
!isWoff2 &&
(!/\.[a-zA-Z]+$/.test(uri) || isSpecialCase)
) {
request.uri += '.html';
}
}
Expand All @@ -40,4 +44,4 @@ const handler = (
// do nothing
return event.request;
}
};
};

0 comments on commit d5e50e2

Please sign in to comment.