diff --git a/lib/hyrax/migrator/crosswalk_metadata.rb b/lib/hyrax/migrator/crosswalk_metadata.rb index 06e8f33..7c10fbe 100644 --- a/lib/hyrax/migrator/crosswalk_metadata.rb +++ b/lib/hyrax/migrator/crosswalk_metadata.rb @@ -109,7 +109,11 @@ def rescue_and_retry_datetime(object, error) raise DateTimeDataError, object end + # don't raise error here, allow child classes to handle + # =~ is a special match operator that returns an index or nil def valid_uri(uri) + return nil unless uri.ascii_only? + uri =~ URI.regexp(%w[http https]) end diff --git a/spec/hyrax/migrator/services/crosswalk_metadata_service_spec.rb b/spec/hyrax/migrator/services/crosswalk_metadata_service_spec.rb index 9bfbdd9..b85d983 100644 --- a/spec/hyrax/migrator/services/crosswalk_metadata_service_spec.rb +++ b/spec/hyrax/migrator/services/crosswalk_metadata_service_spec.rb @@ -127,12 +127,17 @@ describe 'attributes_data' do let(:rdfobject) { RDF::Literal('blah blah') } + let(:rdfobject2) { RDF::URI('http://opaquenamespace.org/ns/subject/Flügelhorn') } let(:error) { URI::InvalidURIError } - it 'raises an error' do + it 'raises an error if there is a string when it should be a uri' do expect { service.send(:attributes_data, rdfobject) }.to raise_error(error) end + it 'raises an error if the uri contains non-ascii characters' do + expect { service.send(:attributes_data, rdfobject2) }.to raise_error(error) + end + context 'when skip field mode is enabled' do before do config.skip_field_mode = true