Using plain JS, I would like to get the current window.location, modify some of its parts and stringify the result - without changing the current location.
Pseudocode:
var oauth_redirect_uri = window.location.deep_clone();
oauth_redirect_uri.hash = "#OAuthCallback/EmailProvider";
var oauth_parameters = {
redirect_uri: oauth_redirect_uri.toString()
};
What code would I have to use instead of the "deep_clone" function?
Try new URL()
var oauth_redirect_uri = new URL(window.location);
oauth_redirect_uri.hash = "#OAuthCallback/EmailProvider";
var oauth_parameters = {
redirect_uri: oauth_redirect_uri.toString()
}
console.log('window.location', window.location.toString())
console.log('oauth_parameters', oauth_parameters)
See https://developer.mozilla.org/en-US/docs/Web/API/URL/URL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With