Os trilhos verificam se um URL é válido

require 'uri'

url =~ URI::regexp
# => 0 if it match, nil if not
Lioruby