Created
June 24, 2010 05:54
-
-
Save kolber/451040 to your computer and use it in GitHub Desktop.
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 ruby | |
require 'net/http' | |
def validate(url) | |
uri = URI.parse(url) | |
response = Net::HTTP.get_response(uri) | |
case response | |
when Net::HTTPSuccess | |
return uri | |
when Net::HTTPRedirection | |
return 'redirected: '+response['location'] | |
else | |
return nil | |
end | |
end | |
#puts validate('http://germanforblack.com') # redirects | |
puts validate('http://germanforblack.com') # doesn't redirect |
Ah, yea, that second URL was meant to read http://www.germanforblack.com
.
I knew your site was using www
redirection, so it popped into my head as a test case.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI, my site will redirect
www
to the root of the domain. Not sure why you chose me though.