'How to get parent URL in JS without using document.referrer

I need to get the parent url which redirect to current page using JS, I find document.referrer can achieve, but our company has some security rules said can't trust that the referrer header is safe - it can be spoofed, omitted, or have an unexpected format.

I am asking are there any other way to achieve this? Thanks!



Solution 1:[1]

The other way I know of is looking into the window object

window.location.origin

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Basitomania