H
Hunt Jon
Hi - I'm working on the script below, which attempts at getting
a user input and validate that the input is formed like a URL.
And if the user fails to input, it should ask again.
require 'uri'
puts "Type a URL"
begin
url = gets.chomp
URI.parse(url) # should raise if a variable 'url' is malformed.
rescue URI::InvalidURIError
puts "That is not a valid URL. Try again."
retry
end
I expect that if I run "URI.parse()" it should raise an error, but
it doesn't happen.
Can anybody help me on this one?
Jon
a user input and validate that the input is formed like a URL.
And if the user fails to input, it should ask again.
require 'uri'
puts "Type a URL"
begin
url = gets.chomp
URI.parse(url) # should raise if a variable 'url' is malformed.
rescue URI::InvalidURIError
puts "That is not a valid URL. Try again."
retry
end
I expect that if I run "URI.parse()" it should raise an error, but
it doesn't happen.
Can anybody help me on this one?
Jon