Skip to content

Commit

Permalink
Update validate-redirect-url.js
Browse files Browse the repository at this point in the history
  • Loading branch information
BermetK123 committed Jan 14, 2025
1 parent 2ff94d5 commit 9fe6e55
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions blocks/identity-block/utils/validate-redirect-url.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
const validateURL = (url) => {
if (!url) return null;
const validationRegEx = /^\/[^/].*$/;
const valid = validationRegEx.test(url);
if (!url) return null;

if (valid) {
return `${window.location.origin}${url}`;
}
try {
const urlObject = new URL(url, window.location.origin);

if (url === "/") {
return url;
}
if (urlObject.origin === window.location.origin) {
console.log(urlObject.pathname+"bermet")
return urlObject.pathname;
}
} catch (e) {

const urlLocation = new URL(url);
sessionStorage.setItem("ArcXP_redirectUrl", "/");
return "/";
}

if (urlLocation.origin === window.location.origin) {
return url;
}

sessionStorage.setItem("ArcXP_redirectUrl", "/");
return "/";
sessionStorage.setItem("ArcXP_redirectUrl", "/");
return "/";
};

export default validateURL;

0 comments on commit 9fe6e55

Please sign in to comment.