diff --git a/lib/json-schema/schema/reader.rb b/lib/json-schema/schema/reader.rb index a4eb664a..40a44718 100644 --- a/lib/json-schema/schema/reader.rb +++ b/lib/json-schema/schema/reader.rb @@ -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 @@ -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 diff --git a/lib/json-schema/util/uri.rb b/lib/json-schema/util/uri.rb index 9f7a3104..e9ceaa0a 100644 --- a/lib/json-schema/util/uri.rb +++ b/lib/json-schema/util/uri.rb @@ -87,8 +87,11 @@ def self.strip_fragment(uri) def self.file_uri(uri) parsed_uri = parse(uri) - - Addressable::URI.convert_path(parsed_uri.path) + if parsed_uri.scheme + parsed_uri + else + Addressable::URI.convert_path(parsed_uri.path) + end end def self.unescape_uri(uri)