Skip to content

Commit

Permalink
feat(single-page-app): add pdf to redirect regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Lagrange committed May 3, 2022
1 parent 1d3d5e9 commit 3d08a93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/constructs/aws/SinglePageApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/singlePageApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3d08a93

Please sign in to comment.