4 ms·
Long URLs Please
- pmjordan 18y agoI can understand the Firefox extension as being something laudable, sure. But an HTTP API? That seems kind of random, given that the URL shorteners work with 30x HTTP responses. I mean, you just need to request the short URL and read out the Location header of the 30x response. It seems... convoluted to go via an additional server.
- darraghcurran 18y agoGood point - what I've done is allow you to piggyback more than one lookup onto a single request. so the plugin will batch them in groups of 4. does that make sense?
- pmjordan 18y agoWell, on the server you're still starting N requests based on my batch request. I guess combined with caching that can make sense, yes. Even so, I'd probably want to implement my own [1] when setting up my own web app for reliability/trust reasons, and because of same-origin restrictions on client-side scripting. (XHR does support not following redirects, but it's kind of pointless with same-origin policy) [1] I did exactly that for http://tweetoftheyear.com/ http://tweetoftheyear.com/ in clojure: (defn lookup-redirect [url] (try (let [response (http-client/url-do url "HEAD" {:follow-redirect false})] (when (#{301 302 303 307} (:return-code response)) (first (get (:header response) "Location")))) (catch java.lang.Throwable t nil)))
- darraghcurran 18y agoI thought so, and I do cache everything nicely in memcache and db. Also it's hard or maybe even impossible? to reliably fetch arbitrary short url using javascript - exposing it as a simple json api makes this easy.
- pmjordan 18y agoYeah, it's only possible on the same hostname as the page you're on, which limits the usefulness and makes the server-side lookup necessary. The JSON solution will only work via a foreign host with a <script> tag as far as I know, which again is something of a trust issue.
- darraghcurran 18y agonice - I've been meaning to learn a bit of clojure. I hear your point on wanting to set up your own - and as you've shown it is easy to do.
- zacharydanger 18y agoTaking the fun out of Rickrolling since 2008.
- trickjarrett 18y agoThere's also longurl.org - doing the same sort of thing.
- darraghcurran 18y agoYep - looks very similar to what I've done, I hadn't seen it until a few days ago. We could do with even more similar services - to balance out the hundreds of url shrinking services.
- Donald 18y agoOr, when using communication mediums where length isn't an issue, you could courteously give your readers a decent url: http://decenturl.com/ http://decenturl.com/ e.g., http://news.ycombinator.decenturl.com/long-urls-please http://news.ycombinator.decenturl.com/long-urls-please And a tidbit for the sadistic: http://hugeurl.com/ http://hugeurl.com/
- nirmal 18y agoI've been using Twitter as part of my blog and have started replacing the href of links with the expanded link. So if you go to my blog or follow me on twitter the links look the same but if you hover on a link the status bar shows the end link. I do this on the server side, with Python code I mentioned http://news.ycombinator.com/item?id=406608 http://news.ycombinator.com/item?id=406608 but it is possible to do it client side as well with something like http://remysharp.com/tinyurlapi http://remysharp.com/tinyurlapi
- pclark 18y agogreat idea. Installed :)
- imusicmash 18y agonice idea and thanks for including an API. sort of related, I wrote a Greasemonkey script to automatically create bit.ly urls as you type a Twitter Tweet. Does it on the fly. Uses the bit.ly API. Check it out at http://userscripts.org/scripts/show/39042 http://userscripts.org/scripts/show/39042
- darraghcurran 18y agoNice! twitter confuses me how it will convert your urls to tiny urls when you don't want to - but won't when you need it to.
- imusicmash 18y agoyah.. I wrote it partly to take that ambiguity away.. also seemed a shame to take up some of your 140 characters with a long url, then only to see that Twitter compressed it for you in the saved Tweet, reminding you that you could have typed more :)
- darraghcurran 18y agoon the typing more front words - have you seen tweetshrink? http://tweetshrink.com/ http://tweetshrink.com/ - it'll shorten words like later to l8r to save characters - http://tweetdeck.com http://tweetdeck.com have integrated it's api into their twitter client
- nirmal 18y agoI've been wanting to use this for a long time but Safari's version of Greasemonkey doesn't support the GM_xmlhttpRequest function anymore.
- kwamenum86 18y agoyou can already use user-entered strings in tinyurl so i dont see the point of using them as an example
- racerrick 18y agoThat's funny. I was just looking for this.
- zack 18y agoThank you; installed.
- meqif 18y agoThe Firefox plugin at addons.mozilla.org is messed up (I looked at the contents and found it's an html document). However, the "Benefit right away by installing the firefox plugin" link has a working xpi. Just a heads-up for anyone wondering why they can't install the plugin. :-) EDIT: Oh, and the statusbar icon is utterly pointless.