require 'uri' hostname = "(?:(?:[\\w\\-]+\\.)+[[:alpha:]]{2,})" host = "(?:#{hostname}|#{URI::DEFAULT_PARSER.pattern[:IPV4ADDR]}|#{URI::DEFAULT_PARSER.pattern[:IPV6ADDR]})" server = "//(?:#{URI::DEFAULT_PARSER.pattern[:USERINFO]}@)?#{host}(?::\\d*)?" absolute_path = "(?:#{URI::DEFAULT_PARSER.pattern[:ABS_PATH]})?" query = URI::DEFAULT_PARSER.pattern[:QUERY] http_uri_regex = Regexp.new("\\A(?:http|https):(?:#{server}#{absolute_path})(?:\\?(?:#{query}))?\\z", Regexp::EXTENDED, 'N')