Skip to content

Instantly share code, notes, and snippets.

@xlson
Created September 6, 2011 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xlson/1197715 to your computer and use it in GitHub Desktop.
Save xlson/1197715 to your computer and use it in GitHub Desktop.
Checks where a shortened url points to
#!/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