by pmjordan · 17y ago · 0 comments
[1] I did exactly that for 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)))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.