Skip to content

Instantly share code, notes, and snippets.

@acanimal
Forked from tahirm/getDomainName.js
Last active August 17, 2018 16:16
Show Gist options
  • Save acanimal/bbde7ae88d9f2028cc5349049515a1f6 to your computer and use it in GitHub Desktop.
Save acanimal/bbde7ae88d9f2028cc5349049515a1f6 to your computer and use it in GitHub Desktop.
Get complete domain name with protocol and port if available. #js #urlFrom http://stackoverflow.com/questions/6941533/javascript-get-protocol-domain-and-port-from-url
const domain = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment