gimsieke/Who-Tweeted-This

improved URL resolution for link shorteners

Closed this issue · 6 comments

Proper short URL resolution. To my surprise, this is all but trivial since XMLHttpRequest transparently resolves all the redirections, and there’s no raw socket HTTP thing. Will try Websockets for this eventually. Until then, we’ll have to put up with what Twitter’s offering in the data-expanded-url attribute. This is the URL, stripped by any GET parameters and fragment identifiers. It will not work well with sites that distinguish their pages by something like ?id=…, potentially giving credit to a tweet that linked to another page of the same site.

Gerrit, you could try http://longurl.org/api - seems to do exactly what you need :)

Longurl.org: yes, seems to provide such a service. But if you think about it, it seems ridiculous. When I GET (or rather, HEAD) the shortened URL using XMLHttpRequest, XMLHttpRequest will make considerable efforts to follow all redirects and will only present the endpoint of the resolution cascade to me. If they added an option to not follow redirects, I could issue requests while the status is 30x and until it is 200. If it is 200, I’d take the Location field of the last 30x response and voilà, this will be the fully resolved URL. The irony is that XMLHttpRequest already has all that information when plodding along, but it won’t expose it. It’s not a security concern. It’s just spec adherence. When they designed the spec, they didn’t think about URL shorteners. The firefox people have already filed a bug for an XMLHttpRequest option. I think I’ll wait for this option to come to Chrome, or try Websockets, or wait for Twitter to provide exact data-expanded-url​s. Querying a 3rd-party service from every client with that extension doesn’t feel right.

Plan: store URL after the clicked page has been opened (intercepting & replacing the default click event, get tab.url after page has been loaded, associate it with tweet path)

Twitter now has an attribute called data-ultimate-url in its links. Let's see whether this lives up to what its name promises. Closing this issue for the time being.

Looks like they read your issue tracker :-)

Mit freundlichen Grüßen
Michael Seiferle

Am 23.08.2011 um 20:56 schrieb gimsieke
reply@reply.github.com:

Twitter now has an attribute called data-ultimate-url in its links. Let's see whether this lives up to what its name promises. Closing this issue for the time being.

Reply to this email directly or view it on GitHub:
#2 (comment)

It seems that these link attributes get rarer and less resolved when there’s a lot of traffic. And tweets by external clients (particularly TweetDeck) get less attention as regarding link resolution then. This is just speculation.

I got fed up of all this and implemented the solution that I proposed above. It’s available starting with v0.7 (released half an hour ago).