Skip to content

Commit

Permalink
Fix CodeQL scanning issue test 3
Browse files Browse the repository at this point in the history
Tryng to pass CodeQL security check on DOM text reinterpreted as HTML problem

ISSUE: ADPM-70
  • Loading branch information
filipkojic committed Oct 4, 2024
1 parent cf1bb24 commit 1aaaaeb
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/views/js/front/adyen-wallets.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ $(document).ready(function () {
event.preventDefault(); // Prevents the form from being submitted for ApplePay button
}

function isValidURL(url) {
try {
const parsedUrl = new URL(url);
return true;
} catch (err) {
return false;
}
}

if (amazonCheckoutSessionId) {
if (checkBox && !checkBox.is(':checked')) {
// If not checked, set it to checked
Expand Down Expand Up @@ -149,12 +140,12 @@ $(document).ready(function () {
window.location.href = response.nextStepUrl;
},
error: function () {
const checkoutUrlValue = checkoutUrl.value;
if (!isValidURL(checkoutUrlValue)) {
console.error('Invalid URL, redirection aborted.');
return;
try {
const checkoutUrlObject = new URL(checkoutUrl.value);
window.location.href = checkoutUrlObject.href;
} catch (err) {
console.error('Invalid URL, redirection aborted.', err);
}
window.location.href = checkoutUrlValue;
}
});
}
Expand Down

0 comments on commit 1aaaaeb

Please sign in to comment.