diff --git a/src/constructs/aws/SinglePageApp.ts b/src/constructs/aws/SinglePageApp.ts index dec0f256..5f11dbf2 100644 --- a/src/constructs/aws/SinglePageApp.ts +++ b/src/constructs/aws/SinglePageApp.ts @@ -42,9 +42,9 @@ export class SinglePageApp extends StaticWebsiteAbstract { * let static files pass. * * Files extensions list taken from: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa - * Add xml as well + * Add pdf and xml as well */ - const code = `var REDIRECT_REGEX = /^[^.]+$|\\.(?!(css|gif|ico|jpg|jpeg|js|png|txt|svg|woff|woff2|ttf|map|json|xml)$)([^.]+$)/; + const code = `var REDIRECT_REGEX = /^[^.]+$|\\.(?!(css|gif|ico|jpg|jpeg|js|png|txt|svg|woff|woff2|ttf|map|json|xml|pdf)$)([^.]+$)/; function handler(event) { var uri = event.request.uri; diff --git a/test/unit/singlePageApp.test.ts b/test/unit/singlePageApp.test.ts index b05f5ea7..2f34c6d1 100644 --- a/test/unit/singlePageApp.test.ts +++ b/test/unit/singlePageApp.test.ts @@ -29,7 +29,7 @@ describe("single page app", () => { Object { "Properties": Object { "AutoPublish": true, - "FunctionCode": "var REDIRECT_REGEX = /^[^.]+$|\\\\.(?!(css|gif|ico|jpg|jpeg|js|png|txt|svg|woff|woff2|ttf|map|json|xml)$)([^.]+$)/; + "FunctionCode": "var REDIRECT_REGEX = /^[^.]+$|\\\\.(?!(css|gif|ico|jpg|jpeg|js|png|txt|svg|woff|woff2|ttf|map|json|xml|pdf)$)([^.]+$)/; function handler(event) { var uri = event.request.uri; @@ -99,7 +99,7 @@ describe("single page app", () => { }); const requestFunction = computeLogicalId("landing", "RequestFunction"); expect(cfTemplate.Resources[requestFunction].Properties.FunctionCode).toMatchInlineSnapshot(` - "var REDIRECT_REGEX = /^[^.]+$|\\\\.(?!(css|gif|ico|jpg|jpeg|js|png|txt|svg|woff|woff2|ttf|map|json|xml)$)([^.]+$)/; + "var REDIRECT_REGEX = /^[^.]+$|\\\\.(?!(css|gif|ico|jpg|jpeg|js|png|txt|svg|woff|woff2|ttf|map|json|xml|pdf)$)([^.]+$)/; function handler(event) { var uri = event.request.uri;