Created
September 6, 2011 14:37
-
-
Save xlson/1197715 to your computer and use it in GitHub Desktop.
Checks where a shortened url points to
This file contains hidden or 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
#!/usr/bin/env groovy | |
def url = args[0] | |
def connection = url.toURL().openConnection() | |
connection.instanceFollowRedirects = false | |
if(connection.responseCode in [300, 301]) { | |
def redirectsTo = connection.getHeaderField('Location') | |
println "Redirects to: $redirectsTo" | |
} else { | |
println "Url not forwarded. [url: $url]" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment