Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flag non-ascii uris #350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/hyrax/migrator/crosswalk_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down