Skip to content

Instantly share code, notes, and snippets.

@guo-yu
Created January 24, 2014 16:19
Show Gist options
  • Save guo-yu/8600574 to your computer and use it in GitHub Desktop.
Save guo-yu/8600574 to your computer and use it in GitHub Desktop.
a simple url parser demo
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