Skip to content

Commit

Permalink
Add second condition for specific JRuby URI in schema reader
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Ševčík committed Nov 1, 2017
1 parent 059d372 commit 7200a6e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/json-schema/schema/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def read(location)
body = if uri.scheme.nil? || uri.scheme == 'file'
uri = JSON::Util::URI.file_uri(uri)
read_file(Pathname.new(uri.path).expand_path)
elsif uri.scheme == 'uri' && uri.path.start_with?("classloader:")
read_file(Pathname.new(uri).expand_path)
else
read_uri(uri)
end
Expand Down Expand Up @@ -128,7 +130,11 @@ def read_uri(uri)

def read_file(pathname)
if accept_file?(pathname)
File.read(JSON::Util::URI.unescaped_path(pathname.to_s))
if pathname.to_s.start_with?("uri:classloader:")
File.read(pathname.to_s)
else
File.read(JSON::Util::URI.unescaped_path(pathname.to_s))
end
else
raise JSON::Schema::ReadRefused.new(pathname.to_s, :file)
end
Expand Down

0 comments on commit 7200a6e

Please sign in to comment.