diff --git a/lib/rdf/util/file.rb b/lib/rdf/util/file.rb index 1e5148ae..4f45b45d 100644 --- a/lib/rdf/util/file.rb +++ b/lib/rdf/util/file.rb @@ -297,7 +297,6 @@ def http_adapter(use_net_http = false) # @yieldreturn [Object] returned from open_file # @raise [IOError] if not found def self.open_file(filename_or_url, proxy: nil, headers: {}, verify_none: false, **options, &block) - filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/) remote_document = nil if filename_or_url.to_s.match?(/^https?/) diff --git a/spec/util_file_spec.rb b/spec/util_file_spec.rb index 9b1ef138..e8d61001 100644 --- a/spec/util_file_spec.rb +++ b/spec/util_file_spec.rb @@ -98,6 +98,17 @@ expect(r).to be_a(RDF::Reader) end + it "yields a file scheme" do + path = fixture_path("test.nt") + path = Gem.win_platform? ? "file:/#{path}" : "file:#{path}" + r = RDF::Util::File.open_file(path) do |f| + expect(f).to respond_to(:read) + opened.opened + RDF::Reader.new + end + expect(r).to be_a(RDF::Reader) + end + it "raises IOError on missing local file" do expect {RDF::Util::File.open_file(fixture_path("not-here"))}.to raise_error IOError opened.opened