Skip to content

Instantly share code, notes, and snippets.

@wutangpaul
Last active October 6, 2023 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wutangpaul/17f8a7be2a8d989f963a935f19be1e9a to your computer and use it in GitHub Desktop.
Save wutangpaul/17f8a7be2a8d989f963a935f19be1e9a to your computer and use it in GitHub Desktop.
Get cross domain hostname for cookies
getCrossDomainCookieUrl = (url) => {
// parse a URL using the WHATWG URL API
const myURL = new URL("https://new.petsafe.com:81/foo");
// Remove all subdomains
myURL.hostname = myURL.hostname.replace(/^([^\.]+)\./, "");
console.log(myURL.hostname);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment