From 7200a6eaca7c812ea73cb8c5b5e045bbffdbcdc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20=C5=A0ev=C4=8D=C3=ADk?= Date: Wed, 1 Nov 2017 15:10:35 +0100 Subject: [PATCH] Add second condition for specific JRuby URI in schema reader --- lib/json-schema/schema/reader.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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