Skip to content

Instantly share code, notes, and snippets.

@rsurjano
Last active September 3, 2016 15:58
Show Gist options
  • Save rsurjano/8c12d9deb6866c166e19f8445a8352a1 to your computer and use it in GitHub Desktop.
Save rsurjano/8c12d9deb6866c166e19f8445a8352a1 to your computer and use it in GitHub Desktop.
Web Utils
var getAbsoluteUrl = (function() {
var a;
return function(url) {
if(!a) a = document.createElement('a');
a.href = url;
return a.href;
};
})();
// Usage
getAbsoluteUrl('/something');
String.prototype.parseHashtag = function() {
return this.replace(/[#]+[A-Za-z0-9-_]+/g, function(t) {
var tag = t.replace("#","%23")
return t.link("http://search.twitter.com/search?q="+tag);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment