diff --git a/lib/json-schema/uri/file.rb b/lib/json-schema/uri/file.rb index 91eddc5b..f44ba3d7 100644 --- a/lib/json-schema/uri/file.rb +++ b/lib/json-schema/uri/file.rb @@ -1,3 +1,4 @@ +require 'rbconfig' require 'uri' module URI @@ -5,28 +6,31 @@ module URI # Ruby does not have built-in support for filesystem URIs, and definitely does not have built-in support for # using open-uri with filesystem URIs class File < Generic - + COMPONENT = [ - :scheme, - :path, + :scheme, + :path, :fragment, :host ].freeze - + def initialize(*arg) - arg[2] = "" + # arg[2] is the 'host'; this logic to set it to "" causes file schemes with UNC to break + # so don't do it on windows platforms + is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) + arg[2] = "" unless is_windows super(*arg) end - + def self.build(args) tmp = Util::make_components_hash(self, args) return super(tmp) end - + def open(*rest, &block) ::File.open(self.path, *rest, &block) end - + @@schemes['FILE'] = File end -end \ No newline at end of file +end