Skip to content

Commit

Permalink
feat: enable redirect to instant lending if atb query param is present
Browse files Browse the repository at this point in the history
  • Loading branch information
mcstover committed Nov 17, 2021
1 parent eb267dc commit bcc9a28
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/live-loan-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ async function getLoanForRequest(type, cache, req) {
async function redirectToUrl(type, cache, req, res) {
try {
const loan = await getLoanForRequest(type, cache, req);

// Standard destination is the borrower profile page
let redirect = `/lend/${loan.id}`;
// If the original request had query params on it, forward those along
const requestUrl = new URL(`${req.protocol}://${req.get('host')}${req.originalUrl}`);
const queryParams = new URLSearchParams(requestUrl.search);
if (queryParams) {
// Update redirect destination for an Instant Lending add to basket flow
if (queryParams.get('atb') === 'true') {
const loanShareAmount = queryParams.get('amount') || '25';
redirect = `/process-instant-lending/${loan.id}/${loanShareAmount}`;
}
// Apply and Pass all original query params
redirect += `?${queryParams}`;
}
res.redirect(302, redirect);
Expand Down

0 comments on commit bcc9a28

Please sign in to comment.