diff --git a/lib/iiif/v3/abstract_resource.rb b/lib/iiif/v3/abstract_resource.rb index c451d8e..d8a1efe 100644 --- a/lib/iiif/v3/abstract_resource.rb +++ b/lib/iiif/v3/abstract_resource.rb @@ -472,11 +472,12 @@ def define_accessor_methods(*keys, &validation) end private + def validate_uri(val, key) - unless val.kind_of?(String) && val =~ /\A#{URI::regexp}\z/ - m = "#{key} value must be a String containing a URI for #{self.class}" - raise IIIF::V3::Presentation::IllegalValueError, m - end + raise ArgumentError if URI(val).scheme.nil? + rescue URI::Error, ArgumentError + m = "#{key} value must be a String containing a URI for #{self.class}" + raise IIIF::V3::Presentation::IllegalValueError, m end end