Skip to content

Commit 4fa08bb

Browse files
author
Sachin Maheshwari
committed
handling specific return url broken cases
1 parent 6afc604 commit 4fa08bb

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

web-assets/js/setupAuth0WithRedirect.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const authSetup = function () {
4242
const IframeLogoutRequestType = "LOGOUT_REQUEST";
4343
const enterpriseCustomers = ['zurich', 'cs'];
4444
const mode = qs['mode'] || 'signIn';
45-
let returnAppUrl = qs['retUrl'];
45+
let returnAppUrl = handleSpecificReturnUrl(qs['retUrl'], 'retUrl');
4646
let appUrl = qs['appUrl'] || false;
4747

4848
if (utmSource &&
@@ -622,6 +622,40 @@ const authSetup = function () {
622622
document.cookie = cname + "=" + cvalue + cdomain + expires + ";path=/";
623623
}
624624

625+
function handleSpecificReturnUrl(value, param) {
626+
try {
627+
const domain = getHostDomain();
628+
const prefixArray = ['apps', 'software'];
629+
if (domain) {
630+
for (let i = 0; i < prefixArray.length; i++) {
631+
if (value.indexOf(prefixArray[i] + domain) > -1) {
632+
const queryParam = window.location.search.substr(1);
633+
if (queryParam) {
634+
const indx = queryParam.indexOf(param);
635+
if (indx > -1) {
636+
//assuming queryParam value like retUrl=xxxxxx
637+
const result = queryParam.substring(indx + param.length + 1);
638+
// verify broken url : https://abc.com/&utm=abc
639+
if (result.indexOf('&') > -1 && result.indexOf('?') === -1) {
640+
return value;
641+
}
642+
return result;
643+
} else {
644+
return value;
645+
}
646+
} else {
647+
return value;
648+
}
649+
}
650+
}
651+
return value;
652+
}
653+
return value;
654+
} catch (e) {
655+
logger('Issue while handling specific query param function', e.message);
656+
return value;
657+
}
658+
};
625659

626660
// execute
627661
init();

0 commit comments

Comments
 (0)