Skip to content

Instantly share code, notes, and snippets.

View willi-mueller's full-sized avatar

Willi Müller willi-mueller

View GitHub Profile
expandLinks: {
func: function (shortLink) {
if (shortLink.context.href.length < 30 && shortLink.context.hostname !="twitter.com") {
$.getJSON('http://almaer.com/endpoint/resolver.php?callback=?',
{url: shortLink.context.href}, function (url) {
if (url.length > 45) { //an URL with > 45 chars can break streamies tweet box layout, 45 is chosen randomly
lastAppearance = url.lastIndexOf("/");
if (lastAppearance < 45 && lastAppearance > 7) { //"http://".length == 7;
url = url.slice(0, lastAppearance+1) + "…"; //generate friendlier URLs by slicing afer the last '/'
}