Last active
January 2, 2016 04:39
-
-
Save tofias/8252138 to your computer and use it in GitHub Desktop.
Get the Long URL for a Short URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get the Long URL for a Short URL | |
-- https://gist.github.com/tofias/8252138 | |
set theClipboard to the clipboard as string | |
set myScript to "curl -sIL " & theClipboard & " | grep ^[lL]ocation | awk 'END{print}' | tr '[:upper:]' '[:lower:]' | tr -d '[[:space:]]' | sed s/'location:'// | tr -d '\n' | pbcopy" | |
do shell script myScript | |
set theClipboard to the clipboard as string | |
display dialog theClipboard with title "Long URL Ready to Paste" giving up after 5 | |
-- TEST URL SHORT: http://t.co/9acY1bnnFg | |
-- SHOULD MAKE LONG URL: http://mosx.tumblr.com/post/72095032814/an-official-statement-on-the-future-of-mac-os-x#_=_ | |
-- Inspired by http://mosx.tumblr.com/post/72105863417/get-every-redirect-of-a-short-url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment