-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
26 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
const validateURL = (url) => { | ||
if (!url) return null; | ||
if (!url) return null; | ||
|
||
try { | ||
const urlObject = new URL(url, window.location.origin); | ||
try { | ||
const urlObject = new URL(url, window.location.origin); | ||
console.log("urlObject " + urlObject.origin) | ||
Check warning on line 6 in blocks/identity-block/utils/validate-redirect-url.js GitHub Actions / ensure_minimum_test_coverage_linting
|
||
console.log("window " +window.location.origin) | ||
Check warning on line 7 in blocks/identity-block/utils/validate-redirect-url.js GitHub Actions / ensure_minimum_test_coverage_linting
|
||
|
||
if (urlObject.origin === window.location.origin) { | ||
return urlObject.pathname; | ||
if (urlObject.origin === window.location.origin) { | ||
console.log("urlObject pth " + urlObject.pathname); | ||
Check warning on line 10 in blocks/identity-block/utils/validate-redirect-url.js GitHub Actions / ensure_minimum_test_coverage_linting
|
||
|
||
if(urlObject.pathname === "/"){ | ||
return urlObject.pathname | ||
} | ||
|
||
if(urlObject.pathname !== "/"){ | ||
return `${urlObject.origin}${urlObject.pathname}` | ||
} | ||
} | ||
|
||
sessionStorage.setItem("ArcXP_redirectUrl", "/"); | ||
return "/"; | ||
} catch (error) { | ||
const storedRedirect = sessionStorage.getItem("ArcXP_redirectUrl"); | ||
if (storedRedirect && storedRedirect.startsWith("/")) { | ||
return storedRedirect; | ||
} | ||
} catch (e) { | ||
|
||
// Default to "/" | ||
sessionStorage.setItem("ArcXP_redirectUrl", "/"); | ||
return "/"; | ||
} | ||
|
||
sessionStorage.setItem("ArcXP_redirectUrl", "/"); | ||
return "/"; | ||
} | ||
}; | ||
|
||
export default validateURL; | ||
export default validateURL; |