Created
January 24, 2014 16:19
-
-
Save guo-yu/8600574 to your computer and use it in GitHub Desktop.
a simple url parser demo
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
var maps = { | |
'weibo': 'fa-weibo' | |
} | |
var parse = function(url) { | |
var a = document.createElement('a'); | |
a.href = url; | |
return a; | |
} | |
var checker = function(url) { | |
var host = parse(url).host.split('.'); | |
host = host.slice(host.length - 2); | |
return maps[host[0]]; | |
} | |
checker('http://git.521000.best.weibo.weibo.com/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment