Skip to content

Instantly share code, notes, and snippets.

@guo-yu
Created January 24, 2014 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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://github.com.weibo.weibo.com/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment