Created
December 10, 2014 12:32
-
-
Save saltun/fccff999acc2b0dba95e to your computer and use it in GitHub Desktop.
JavaScript get URL Path Function
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
/* | |
* Savaş Can ALTUN < savascanaltun@gmail.com > | |
* Github : @saltun | |
*/ | |
function url_split(url){ | |
url_parts = url.split('/'); | |
domain_name_parts = url_parts[2].split(':'); | |
domain_name = domain_name_parts[0]; | |
if ( domain_name.substring(0,4) == 'www.' ) domain_name = domain_name.substring(4); | |
return (domain_name); | |
} | |
var sonuc=url_split("http://savascanaltun.com"); | |
document.write(sonuc); // savascanaltun.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment