From d257cf7a7bfd12587e89e3cdaf2330dcf46532a4 Mon Sep 17 00:00:00 2001 From: Aaron shiel <57824522+aaronshiel@users.noreply.github.com> Date: Mon, 14 Nov 2022 14:39:13 -0800 Subject: [PATCH] rewrite-default-index-update (#34) --- scripts/mentorpal-rewrite-default-index-s3-origin.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/mentorpal-rewrite-default-index-s3-origin.js b/scripts/mentorpal-rewrite-default-index-s3-origin.js index a6399fe..547f902 100644 --- a/scripts/mentorpal-rewrite-default-index-s3-origin.js +++ b/scripts/mentorpal-rewrite-default-index-s3-origin.js @@ -4,7 +4,7 @@ * @param {*} event * @returns */ -function handler(event) { + function handler(event) { var request = event.request; var uri = request.uri; @@ -22,14 +22,8 @@ function handler(event) { return response; } - if (uri == "/home" || uri == "/home/") { - request.uri = "/home/index.html"; - } - if (uri == "/chat" || uri == "/chat/") { - request.uri = "/chat/index.html"; - } - if (uri == "/admin" || uri == "/admin/") { - request.uri = "/admin/index.html"; + if (!uri.includes(".")) { + request.uri = "/" + uri.split("/").filter(e=>e.length).join("/") +"/index.html"; } return request;