Skip to content

Commit

Permalink
do not drop url params on re-route to home (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronshiel authored Jun 22, 2023
1 parent c22bb8d commit 5c9759b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/mentorpal-rewrite-default-index-s3-origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,25 @@
}

if (uri == "" || uri == "/") {
var finalLocation = "/home/"
try{
// uri may not have the url
var queryParams = request.querystring || "{}"
var queryKeys = Object.keys(queryParams)
var urlParams = queryKeys.map((key)=>`${key}=${queryParams[key]["value"]}`)
if (urlParams.length > 0){
finalLocation = `/home/?${urlParams.join("&")}`
}
}catch(e){
console.log("failed to parse and set query params")
}

var response = {
statusCode: 302,
statusDescription: "Found",
headers: { location: { value: "/home/" } },
headers: { location: { value: finalLocation } },
};

return response;
}

Expand Down

0 comments on commit 5c9759b

Please sign in to comment.