Created
July 15, 2013 18:21
-
-
Save caius/6002173 to your computer and use it in GitHub Desktop.
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
require "uri" | |
urls = [ | |
"http://caius.name/", | |
"http:/caius.name/", | |
"http://ca]ius.name/", | |
"http://cai;us.name/", | |
"http://caius", | |
"http://", | |
"caius.name", | |
] | |
headers = %w(url pass-regex? pass-parse?) | |
i = (headers | urls).map {|x| x.length }.max | |
headers.each do |h| | |
printf " %-#{i}s", h | |
end | |
puts | |
urls.each do |u| | |
printf " %-#{i+5}s", u | |
if u =~ URI.regexp | |
printf " %-#{i}s", "β" | |
else | |
printf " %-#{i}s", "π" | |
end | |
begin | |
URI(u) | |
printf " %-#{i}s", "β" | |
rescue URI::InvalidURIError => e | |
printf " %-#{i}s", "π" | |
end | |
puts | |
end | |
# >> url pass-regex? pass-parse? | |
# >> http://caius.name/ β β | |
# >> http:/caius.name/ β β | |
# >> http://ca]ius.name/ β π | |
# >> http://cai;us.name/ β π | |
# >> http://caius β β | |
# >> http:// β π | |
# >> caius.name π β |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment