diff --git a/src/static-website/index.ts b/src/static-website/index.ts index d24d9b6d..fb394ff4 100644 --- a/src/static-website/index.ts +++ b/src/static-website/index.ts @@ -239,12 +239,12 @@ function rewriteFunctionCode(): string { return `function handler(event) { const request = event.request; const uri = request.uri; - const hasExtension = /\.[a-zA-Z0-9]+$/.test(uri); + const hasExtension = /\\.[a-zA-Z0-9]+$/.test(uri); if (!hasExtension) { request.uri = '/index.html'; } return request; - }`; +}`; } function redirectFunctionCode(domainName: string): string { @@ -257,5 +257,5 @@ function redirectFunctionCode(domainName: string): string { value: 'https://${domainName}', }, }, - };`; +};`; } diff --git a/test/static-website/__snapshots__/static-website.test.ts.snap b/test/static-website/__snapshots__/static-website.test.ts.snap index 8a103bc4..1f97f811 100644 --- a/test/static-website/__snapshots__/static-website.test.ts.snap +++ b/test/static-website/__snapshots__/static-website.test.ts.snap @@ -644,7 +644,7 @@ exports[`StaticWebsite 1`] = ` value: 'https://www.my-site.com', }, }, - };", +};", "FunctionConfig": { "Comment": "eu-west-1StackStaticWebsiRedirectFunction172BEC3F", "Runtime": "cloudfront-js-2.0", @@ -718,12 +718,12 @@ exports[`StaticWebsite 1`] = ` "FunctionCode": "function handler(event) { const request = event.request; const uri = request.uri; - const hasExtension = /.[a-zA-Z0-9]+$/.test(uri); + const hasExtension = /\\.[a-zA-Z0-9]+$/.test(uri); if (!hasExtension) { request.uri = '/index.html'; } return request; - }", +}", "FunctionConfig": { "Comment": "eu-west-1StackStaticWebsiteRewriteFunction4EBA86F3", "Runtime": "cloudfront-js-2.0",