Last active
July 6, 2017 13:16
-
-
Save marco-kretz/a1a3ebd9fae877225ce2005178a92cc1 to your computer and use it in GitHub Desktop.
JavaScript: Extract hostname from URL
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
function getUrlHost(url) { | |
var parser = document.createElement('a'); | |
parser.href = url; | |
return parser.hostname; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment