Skip to content

Commit a076b1d

Browse files
author
Milan Ševčík
committed
Add second condition for specific JRuby URI in schema reader
1 parent 059d372 commit a076b1d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/json-schema/schema/reader.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def read(location)
8787
body = if uri.scheme.nil? || uri.scheme == 'file'
8888
uri = JSON::Util::URI.file_uri(uri)
8989
read_file(Pathname.new(uri.path).expand_path)
90+
elsif uri.scheme == 'uri' && uri.path.start_with?("classloader:")
91+
read_file(Pathname.new(uri).expand_path)
9092
else
9193
read_uri(uri)
9294
end
@@ -128,7 +130,11 @@ def read_uri(uri)
128130

129131
def read_file(pathname)
130132
if accept_file?(pathname)
131-
File.read(JSON::Util::URI.unescaped_path(pathname.to_s))
133+
if pathname.to_s.start_with?("uri:classloader:")
134+
File.read(pathname.to_s)
135+
else
136+
File.read(JSON::Util::URI.unescaped_path(pathname.to_s))
137+
end
132138
else
133139
raise JSON::Schema::ReadRefused.new(pathname.to_s, :file)
134140
end

lib/json-schema/util/uri.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def self.strip_fragment(uri)
8787

8888
def self.file_uri(uri)
8989
parsed_uri = parse(uri)
90-
if not parsed_uri.scheme.nil?
90+
if parsed_uri.scheme
9191
parsed_uri
9292
else
9393
Addressable::URI.convert_path(parsed_uri.path)

0 commit comments

Comments
 (0)