Created
August 23, 2017 08:05
-
-
Save Bizunow/c945551e2cec9649edbe5bf2ac968cdc to your computer and use it in GitHub Desktop.
[Check URL domain] #js
This file contains hidden or 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
// checkDomain('https://www.instagram.com/bizunow/', 'www.instagram.com') // === true | |
// checkDomain('https://www.google.ru/', 'www.instagram.com') // === false | |
// checkDomain('Test test test', 'www.instagram.com') // === false | |
function checkDomain(url, domain) { | |
var a = document.createElement('a'); | |
a.href = url; | |
return a.hostname == domain; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment