Commit 58c49966 authored by James Lopez's avatar James Lopez

updated validator based on feedback

parent 1e1bf322
...@@ -29,9 +29,7 @@ class AddressableUrlValidator < ActiveModel::EachValidator ...@@ -29,9 +29,7 @@ class AddressableUrlValidator < ActiveModel::EachValidator
value.strip! value.strip!
valid_uri?(value) && valid_protocol?(value) valid_protocol?(value) && valid_uri?(value)
rescue Addressable::URI::InvalidURIError
false
end end
def default_options def default_options
...@@ -40,6 +38,8 @@ class AddressableUrlValidator < ActiveModel::EachValidator ...@@ -40,6 +38,8 @@ class AddressableUrlValidator < ActiveModel::EachValidator
def valid_uri?(value) def valid_uri?(value)
Addressable::URI.parse(value).is_a?(Addressable::URI) Addressable::URI.parse(value).is_a?(Addressable::URI)
rescue Addressable::URI::InvalidURIError
false
end end
def valid_protocol?(value) def valid_protocol?(value)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment