Bump vendored uri to 1.0.1

This commit is contained in:
David Rodríguez 2024-11-08 12:20:35 +01:00 committed by Hiroshi SHIBATA
parent 1b137a94a4
commit bb6a3edadf
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2
19 changed files with 209 additions and 130 deletions

View File

@ -1,6 +1,6 @@
# frozen_string_literal: false
# Bundler::URI is a module providing classes to handle Uniform Resource Identifiers
# (RFC2396[http://tools.ietf.org/html/rfc2396]).
# (RFC2396[https://www.rfc-editor.org/rfc/rfc2396]).
#
# == Features
#
@ -47,14 +47,14 @@
# A good place to view an RFC spec is http://www.ietf.org/rfc.html.
#
# Here is a list of all related RFC's:
# - RFC822[http://tools.ietf.org/html/rfc822]
# - RFC1738[http://tools.ietf.org/html/rfc1738]
# - RFC2255[http://tools.ietf.org/html/rfc2255]
# - RFC2368[http://tools.ietf.org/html/rfc2368]
# - RFC2373[http://tools.ietf.org/html/rfc2373]
# - RFC2396[http://tools.ietf.org/html/rfc2396]
# - RFC2732[http://tools.ietf.org/html/rfc2732]
# - RFC3986[http://tools.ietf.org/html/rfc3986]
# - RFC822[https://www.rfc-editor.org/rfc/rfc822]
# - RFC1738[https://www.rfc-editor.org/rfc/rfc1738]
# - RFC2255[https://www.rfc-editor.org/rfc/rfc2255]
# - RFC2368[https://www.rfc-editor.org/rfc/rfc2368]
# - RFC2373[https://www.rfc-editor.org/rfc/rfc2373]
# - RFC2396[https://www.rfc-editor.org/rfc/rfc2396]
# - RFC2732[https://www.rfc-editor.org/rfc/rfc2732]
# - RFC3986[https://www.rfc-editor.org/rfc/rfc3986]
#
# == Class tree
#

View File

@ -13,26 +13,52 @@ require_relative "rfc2396_parser"
require_relative "rfc3986_parser"
module Bundler::URI
include RFC2396_REGEXP
REGEXP = RFC2396_REGEXP
Parser = RFC2396_Parser
RFC3986_PARSER = RFC3986_Parser.new
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
RFC2396_PARSER = RFC2396_Parser.new
Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
# Bundler::URI::Parser.new
DEFAULT_PARSER = Parser.new
DEFAULT_PARSER.pattern.each_pair do |sym, str|
unless REGEXP::PATTERN.const_defined?(sym)
REGEXP::PATTERN.const_set(sym, str)
RFC3986_PARSER = RFC3986_Parser.new
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
DEFAULT_PARSER = RFC3986_PARSER
Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
def self.parser=(parser = RFC3986_PARSER)
remove_const(:Parser) if defined?(::Bundler::URI::Parser)
const_set("Parser", parser.class)
remove_const(:REGEXP) if defined?(::Bundler::URI::REGEXP)
remove_const(:PATTERN) if defined?(::Bundler::URI::PATTERN)
if Parser == RFC2396_Parser
const_set("REGEXP", Bundler::URI::RFC2396_REGEXP)
const_set("PATTERN", Bundler::URI::RFC2396_REGEXP::PATTERN)
Parser.new.pattern.each_pair do |sym, str|
unless REGEXP::PATTERN.const_defined?(sym)
REGEXP::PATTERN.const_set(sym, str)
end
end
end
Parser.new.regexp.each_pair do |sym, str|
remove_const(sym) if const_defined?(sym)
const_set(sym, str)
end
end
DEFAULT_PARSER.regexp.each_pair do |sym, str|
const_set(sym, str)
self.parser = RFC3986_PARSER
def self.const_missing(const)
if const == :REGEXP
warn "Bundler::URI::REGEXP is obsolete. Use Bundler::URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
Bundler::URI::RFC2396_REGEXP
elsif value = RFC2396_PARSER.regexp[const]
warn "Bundler::URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
value
elsif value = RFC2396_Parser.const_get(const)
warn "Bundler::URI::#{const} is obsolete. Use RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
value
else
super
end
end
Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
module Util # :nodoc:
def make_components_hash(klass, array_hash)
@ -170,7 +196,7 @@ module Bundler::URI
# ["fragment", "top"]]
#
def self.split(uri)
RFC3986_PARSER.split(uri)
DEFAULT_PARSER.split(uri)
end
# Returns a new \Bundler::URI object constructed from the given string +uri+:
@ -184,7 +210,7 @@ module Bundler::URI
# if it may contain invalid Bundler::URI characters.
#
def self.parse(uri)
RFC3986_PARSER.parse(uri)
DEFAULT_PARSER.parse(uri)
end
# Merges the given Bundler::URI strings +str+
@ -211,7 +237,7 @@ module Bundler::URI
# # => #<Bundler::URI::HTTP http://example.com/foo/bar>
#
def self.join(*str)
RFC3986_PARSER.join(*str)
DEFAULT_PARSER.join(*str)
end
#

View File

@ -70,17 +70,17 @@ module Bundler::URI
# raise InvalidURIError
def check_userinfo(user)
raise Bundler::URI::InvalidURIError, "can not set userinfo for file Bundler::URI"
raise Bundler::URI::InvalidURIError, "cannot set userinfo for file Bundler::URI"
end
# raise InvalidURIError
def check_user(user)
raise Bundler::URI::InvalidURIError, "can not set user for file Bundler::URI"
raise Bundler::URI::InvalidURIError, "cannot set user for file Bundler::URI"
end
# raise InvalidURIError
def check_password(user)
raise Bundler::URI::InvalidURIError, "can not set password for file Bundler::URI"
raise Bundler::URI::InvalidURIError, "cannot set password for file Bundler::URI"
end
# do nothing

View File

@ -17,7 +17,7 @@ module Bundler::URI
# This class will be redesigned because of difference of implementations;
# the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it
# is a good summary about the de facto spec.
# http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
# https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04
#
class FTP < Generic
# A Default port of 21 for Bundler::URI::FTP.

View File

@ -82,7 +82,7 @@ module Bundler::URI
if args.kind_of?(Array)
return self.build(args.collect{|x|
if x.is_a?(String)
DEFAULT_PARSER.escape(x)
Bundler::URI::RFC2396_PARSER.escape(x)
else
x
end
@ -91,7 +91,7 @@ module Bundler::URI
tmp = {}
args.each do |key, value|
tmp[key] = if value
DEFAULT_PARSER.escape(value)
Bundler::URI::RFC2396_PARSER.escape(value)
else
value
end
@ -393,7 +393,7 @@ module Bundler::URI
def check_user(v)
if @opaque
raise InvalidURIError,
"can not set user with opaque"
"cannot set user with opaque"
end
return v unless v
@ -417,7 +417,7 @@ module Bundler::URI
def check_password(v, user = @user)
if @opaque
raise InvalidURIError,
"can not set password with opaque"
"cannot set password with opaque"
end
return v unless v
@ -596,7 +596,7 @@ module Bundler::URI
if @opaque
raise InvalidURIError,
"can not set host with registry or opaque"
"cannot set host with registry or opaque"
elsif parser.regexp[:HOST] !~ v
raise InvalidComponentError,
"bad component(expected host component): #{v}"
@ -685,7 +685,7 @@ module Bundler::URI
if @opaque
raise InvalidURIError,
"can not set port with registry or opaque"
"cannot set port with registry or opaque"
elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v
raise InvalidComponentError,
"bad component(expected port component): #{v.inspect}"
@ -733,17 +733,17 @@ module Bundler::URI
end
def check_registry(v) # :nodoc:
raise InvalidURIError, "can not set registry"
raise InvalidURIError, "cannot set registry"
end
private :check_registry
def set_registry(v) #:nodoc:
raise InvalidURIError, "can not set registry"
raise InvalidURIError, "cannot set registry"
end
protected :set_registry
def registry=(v)
raise InvalidURIError, "can not set registry"
raise InvalidURIError, "cannot set registry"
end
#
@ -866,7 +866,7 @@ module Bundler::URI
# hier_part = ( net_path | abs_path ) [ "?" query ]
if @host || @port || @user || @path # userinfo = @user + ':' + @password
raise InvalidURIError,
"can not set opaque with host, port, userinfo or path"
"cannot set opaque with host, port, userinfo or path"
elsif v && parser.regexp[:OPAQUE] !~ v
raise InvalidComponentError,
"bad component(expected opaque component): #{v}"
@ -945,7 +945,7 @@ module Bundler::URI
# == Description
#
# Bundler::URI has components listed in order of decreasing significance from left to right,
# see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
# see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3.
#
# == Usage
#
@ -1235,7 +1235,7 @@ module Bundler::URI
return rel, rel
end
# you can modify `rel', but can not `oth'.
# you can modify `rel', but cannot `oth'.
return oth, rel
end
private :route_from0
@ -1260,7 +1260,7 @@ module Bundler::URI
# #=> #<Bundler::URI::Generic /main.rbx?page=1>
#
def route_from(oth)
# you can modify `rel', but can not `oth'.
# you can modify `rel', but cannot `oth'.
begin
oth, rel = route_from0(oth)
rescue
@ -1364,6 +1364,9 @@ module Bundler::URI
str << ':'
str << @port.to_s
end
if (@host || @port) && !@path.empty? && !@path.start_with?('/')
str << '/'
end
str << @path
if @query
str << '?'
@ -1399,19 +1402,6 @@ module Bundler::URI
self.component_ary.eql?(oth.component_ary)
end
=begin
--- Bundler::URI::Generic#===(oth)
=end
# def ===(oth)
# raise NotImplementedError
# end
=begin
=end
# Returns an Array of the components defined from the COMPONENT Array.
def component_ary
component.collect do |x|

View File

@ -85,7 +85,7 @@ module Bundler::URI
# == Description
#
# Returns the authority for an HTTP uri, as defined in
# https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
# https://www.rfc-editor.org/rfc/rfc3986#section-3.2.
#
#
# Example:
@ -106,7 +106,7 @@ module Bundler::URI
# == Description
#
# Returns the origin for an HTTP uri, as defined in
# https://datatracker.ietf.org/doc/html/rfc6454.
# https://www.rfc-editor.org/rfc/rfc6454.
#
#
# Example:

View File

@ -140,11 +140,11 @@ module Bundler::URI
if !scheme
raise InvalidURIError,
"bad Bundler::URI(absolute but no scheme): #{uri}"
"bad Bundler::URI (absolute but no scheme): #{uri}"
end
if !opaque && (!path && (!host && !registry))
raise InvalidURIError,
"bad Bundler::URI(absolute but no path): #{uri}"
"bad Bundler::URI (absolute but no path): #{uri}"
end
when @regexp[:REL_URI]
@ -173,7 +173,7 @@ module Bundler::URI
# server = [ [ userinfo "@" ] hostport ]
else
raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri}"
raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri}"
end
path = '' if !path && !opaque # (see RFC2396 Section 5.2)

View File

@ -78,7 +78,7 @@ module Bundler::URI
begin
uri = uri.to_str
rescue NoMethodError
raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri.inspect}"
raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri.inspect}"
end
uri.ascii_only? or
raise InvalidURIError, "Bundler::URI must be ascii only #{uri.dump}"
@ -127,7 +127,7 @@ module Bundler::URI
m["fragment"]
]
else
raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri.inspect}"
raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri.inspect}"
end
end
@ -135,12 +135,35 @@ module Bundler::URI
Bundler::URI.for(*self.split(uri), self)
end
def join(*uris) # :nodoc:
uris[0] = convert_to_uri(uris[0])
uris.inject :merge
end
# Compatibility for RFC2396 parser
def extract(str, schemes = nil, &block) # :nodoc:
warn "Bundler::URI::RFC3986_PARSER.extract is obsoleted. Use Bundler::URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE
RFC2396_PARSER.extract(str, schemes, &block)
end
# Compatibility for RFC2396 parser
def make_regexp(schemes = nil) # :nodoc:
warn "Bundler::URI::RFC3986_PARSER.make_regexp is obsoleted. Use Bundler::URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE
RFC2396_PARSER.make_regexp(schemes)
end
# Compatibility for RFC2396 parser
def escape(str, unsafe = nil) # :nodoc:
warn "Bundler::URI::RFC3986_PARSER.escape is obsoleted. Use Bundler::URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE
unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str)
end
# Compatibility for RFC2396 parser
def unescape(str, escaped = nil) # :nodoc:
warn "Bundler::URI::RFC3986_PARSER.unescape is obsoleted. Use Bundler::URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE
escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str)
end
@@to_s = Kernel.instance_method(:to_s)
if @@to_s.respond_to?(:bind_call)
def inspect

View File

@ -1,6 +1,6 @@
module Bundler::URI
# :stopdoc:
VERSION_CODE = '001301'.freeze
VERSION_CODE = '010001'.freeze
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
# :startdoc:
end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: false
# Gem::URI is a module providing classes to handle Uniform Resource Identifiers
# (RFC2396[http://tools.ietf.org/html/rfc2396]).
# (RFC2396[https://www.rfc-editor.org/rfc/rfc2396]).
#
# == Features
#
@ -47,14 +47,14 @@
# A good place to view an RFC spec is http://www.ietf.org/rfc.html.
#
# Here is a list of all related RFC's:
# - RFC822[http://tools.ietf.org/html/rfc822]
# - RFC1738[http://tools.ietf.org/html/rfc1738]
# - RFC2255[http://tools.ietf.org/html/rfc2255]
# - RFC2368[http://tools.ietf.org/html/rfc2368]
# - RFC2373[http://tools.ietf.org/html/rfc2373]
# - RFC2396[http://tools.ietf.org/html/rfc2396]
# - RFC2732[http://tools.ietf.org/html/rfc2732]
# - RFC3986[http://tools.ietf.org/html/rfc3986]
# - RFC822[https://www.rfc-editor.org/rfc/rfc822]
# - RFC1738[https://www.rfc-editor.org/rfc/rfc1738]
# - RFC2255[https://www.rfc-editor.org/rfc/rfc2255]
# - RFC2368[https://www.rfc-editor.org/rfc/rfc2368]
# - RFC2373[https://www.rfc-editor.org/rfc/rfc2373]
# - RFC2396[https://www.rfc-editor.org/rfc/rfc2396]
# - RFC2732[https://www.rfc-editor.org/rfc/rfc2732]
# - RFC3986[https://www.rfc-editor.org/rfc/rfc3986]
#
# == Class tree
#

View File

@ -13,26 +13,52 @@ require_relative "rfc2396_parser"
require_relative "rfc3986_parser"
module Gem::URI
include RFC2396_REGEXP
REGEXP = RFC2396_REGEXP
Parser = RFC2396_Parser
RFC3986_PARSER = RFC3986_Parser.new
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
RFC2396_PARSER = RFC2396_Parser.new
Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
# Gem::URI::Parser.new
DEFAULT_PARSER = Parser.new
DEFAULT_PARSER.pattern.each_pair do |sym, str|
unless REGEXP::PATTERN.const_defined?(sym)
REGEXP::PATTERN.const_set(sym, str)
RFC3986_PARSER = RFC3986_Parser.new
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
DEFAULT_PARSER = RFC3986_PARSER
Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
def self.parser=(parser = RFC3986_PARSER)
remove_const(:Parser) if defined?(::Gem::URI::Parser)
const_set("Parser", parser.class)
remove_const(:REGEXP) if defined?(::Gem::URI::REGEXP)
remove_const(:PATTERN) if defined?(::Gem::URI::PATTERN)
if Parser == RFC2396_Parser
const_set("REGEXP", Gem::URI::RFC2396_REGEXP)
const_set("PATTERN", Gem::URI::RFC2396_REGEXP::PATTERN)
Parser.new.pattern.each_pair do |sym, str|
unless REGEXP::PATTERN.const_defined?(sym)
REGEXP::PATTERN.const_set(sym, str)
end
end
end
Parser.new.regexp.each_pair do |sym, str|
remove_const(sym) if const_defined?(sym)
const_set(sym, str)
end
end
DEFAULT_PARSER.regexp.each_pair do |sym, str|
const_set(sym, str)
self.parser = RFC3986_PARSER
def self.const_missing(const)
if const == :REGEXP
warn "Gem::URI::REGEXP is obsolete. Use Gem::URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
Gem::URI::RFC2396_REGEXP
elsif value = RFC2396_PARSER.regexp[const]
warn "Gem::URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
value
elsif value = RFC2396_Parser.const_get(const)
warn "Gem::URI::#{const} is obsolete. Use RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
value
else
super
end
end
Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
module Util # :nodoc:
def make_components_hash(klass, array_hash)
@ -170,7 +196,7 @@ module Gem::URI
# ["fragment", "top"]]
#
def self.split(uri)
RFC3986_PARSER.split(uri)
DEFAULT_PARSER.split(uri)
end
# Returns a new \Gem::URI object constructed from the given string +uri+:
@ -184,7 +210,7 @@ module Gem::URI
# if it may contain invalid Gem::URI characters.
#
def self.parse(uri)
RFC3986_PARSER.parse(uri)
DEFAULT_PARSER.parse(uri)
end
# Merges the given Gem::URI strings +str+
@ -211,7 +237,7 @@ module Gem::URI
# # => #<Gem::URI::HTTP http://example.com/foo/bar>
#
def self.join(*str)
RFC3986_PARSER.join(*str)
DEFAULT_PARSER.join(*str)
end
#

View File

@ -70,17 +70,17 @@ module Gem::URI
# raise InvalidURIError
def check_userinfo(user)
raise Gem::URI::InvalidURIError, "can not set userinfo for file Gem::URI"
raise Gem::URI::InvalidURIError, "cannot set userinfo for file Gem::URI"
end
# raise InvalidURIError
def check_user(user)
raise Gem::URI::InvalidURIError, "can not set user for file Gem::URI"
raise Gem::URI::InvalidURIError, "cannot set user for file Gem::URI"
end
# raise InvalidURIError
def check_password(user)
raise Gem::URI::InvalidURIError, "can not set password for file Gem::URI"
raise Gem::URI::InvalidURIError, "cannot set password for file Gem::URI"
end
# do nothing

View File

@ -17,7 +17,7 @@ module Gem::URI
# This class will be redesigned because of difference of implementations;
# the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it
# is a good summary about the de facto spec.
# http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
# https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04
#
class FTP < Generic
# A Default port of 21 for Gem::URI::FTP.

View File

@ -82,7 +82,7 @@ module Gem::URI
if args.kind_of?(Array)
return self.build(args.collect{|x|
if x.is_a?(String)
DEFAULT_PARSER.escape(x)
Gem::URI::RFC2396_PARSER.escape(x)
else
x
end
@ -91,7 +91,7 @@ module Gem::URI
tmp = {}
args.each do |key, value|
tmp[key] = if value
DEFAULT_PARSER.escape(value)
Gem::URI::RFC2396_PARSER.escape(value)
else
value
end
@ -393,7 +393,7 @@ module Gem::URI
def check_user(v)
if @opaque
raise InvalidURIError,
"can not set user with opaque"
"cannot set user with opaque"
end
return v unless v
@ -417,7 +417,7 @@ module Gem::URI
def check_password(v, user = @user)
if @opaque
raise InvalidURIError,
"can not set password with opaque"
"cannot set password with opaque"
end
return v unless v
@ -596,7 +596,7 @@ module Gem::URI
if @opaque
raise InvalidURIError,
"can not set host with registry or opaque"
"cannot set host with registry or opaque"
elsif parser.regexp[:HOST] !~ v
raise InvalidComponentError,
"bad component(expected host component): #{v}"
@ -685,7 +685,7 @@ module Gem::URI
if @opaque
raise InvalidURIError,
"can not set port with registry or opaque"
"cannot set port with registry or opaque"
elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v
raise InvalidComponentError,
"bad component(expected port component): #{v.inspect}"
@ -733,17 +733,17 @@ module Gem::URI
end
def check_registry(v) # :nodoc:
raise InvalidURIError, "can not set registry"
raise InvalidURIError, "cannot set registry"
end
private :check_registry
def set_registry(v) #:nodoc:
raise InvalidURIError, "can not set registry"
raise InvalidURIError, "cannot set registry"
end
protected :set_registry
def registry=(v)
raise InvalidURIError, "can not set registry"
raise InvalidURIError, "cannot set registry"
end
#
@ -866,7 +866,7 @@ module Gem::URI
# hier_part = ( net_path | abs_path ) [ "?" query ]
if @host || @port || @user || @path # userinfo = @user + ':' + @password
raise InvalidURIError,
"can not set opaque with host, port, userinfo or path"
"cannot set opaque with host, port, userinfo or path"
elsif v && parser.regexp[:OPAQUE] !~ v
raise InvalidComponentError,
"bad component(expected opaque component): #{v}"
@ -945,7 +945,7 @@ module Gem::URI
# == Description
#
# Gem::URI has components listed in order of decreasing significance from left to right,
# see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
# see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3.
#
# == Usage
#
@ -1235,7 +1235,7 @@ module Gem::URI
return rel, rel
end
# you can modify `rel', but can not `oth'.
# you can modify `rel', but cannot `oth'.
return oth, rel
end
private :route_from0
@ -1260,7 +1260,7 @@ module Gem::URI
# #=> #<Gem::URI::Generic /main.rbx?page=1>
#
def route_from(oth)
# you can modify `rel', but can not `oth'.
# you can modify `rel', but cannot `oth'.
begin
oth, rel = route_from0(oth)
rescue
@ -1364,6 +1364,9 @@ module Gem::URI
str << ':'
str << @port.to_s
end
if (@host || @port) && !@path.empty? && !@path.start_with?('/')
str << '/'
end
str << @path
if @query
str << '?'
@ -1399,19 +1402,6 @@ module Gem::URI
self.component_ary.eql?(oth.component_ary)
end
=begin
--- Gem::URI::Generic#===(oth)
=end
# def ===(oth)
# raise NotImplementedError
# end
=begin
=end
# Returns an Array of the components defined from the COMPONENT Array.
def component_ary
component.collect do |x|

View File

@ -85,7 +85,7 @@ module Gem::URI
# == Description
#
# Returns the authority for an HTTP uri, as defined in
# https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
# https://www.rfc-editor.org/rfc/rfc3986#section-3.2.
#
#
# Example:
@ -106,7 +106,7 @@ module Gem::URI
# == Description
#
# Returns the origin for an HTTP uri, as defined in
# https://datatracker.ietf.org/doc/html/rfc6454.
# https://www.rfc-editor.org/rfc/rfc6454.
#
#
# Example:

View File

@ -140,11 +140,11 @@ module Gem::URI
if !scheme
raise InvalidURIError,
"bad Gem::URI(absolute but no scheme): #{uri}"
"bad Gem::URI (absolute but no scheme): #{uri}"
end
if !opaque && (!path && (!host && !registry))
raise InvalidURIError,
"bad Gem::URI(absolute but no path): #{uri}"
"bad Gem::URI (absolute but no path): #{uri}"
end
when @regexp[:REL_URI]
@ -173,7 +173,7 @@ module Gem::URI
# server = [ [ userinfo "@" ] hostport ]
else
raise InvalidURIError, "bad Gem::URI(is not Gem::URI?): #{uri}"
raise InvalidURIError, "bad Gem::URI (is not Gem::URI?): #{uri}"
end
path = '' if !path && !opaque # (see RFC2396 Section 5.2)

View File

@ -78,7 +78,7 @@ module Gem::URI
begin
uri = uri.to_str
rescue NoMethodError
raise InvalidURIError, "bad Gem::URI(is not Gem::URI?): #{uri.inspect}"
raise InvalidURIError, "bad Gem::URI (is not Gem::URI?): #{uri.inspect}"
end
uri.ascii_only? or
raise InvalidURIError, "Gem::URI must be ascii only #{uri.dump}"
@ -127,7 +127,7 @@ module Gem::URI
m["fragment"]
]
else
raise InvalidURIError, "bad Gem::URI(is not Gem::URI?): #{uri.inspect}"
raise InvalidURIError, "bad Gem::URI (is not Gem::URI?): #{uri.inspect}"
end
end
@ -135,12 +135,35 @@ module Gem::URI
Gem::URI.for(*self.split(uri), self)
end
def join(*uris) # :nodoc:
uris[0] = convert_to_uri(uris[0])
uris.inject :merge
end
# Compatibility for RFC2396 parser
def extract(str, schemes = nil, &block) # :nodoc:
warn "Gem::URI::RFC3986_PARSER.extract is obsoleted. Use Gem::URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE
RFC2396_PARSER.extract(str, schemes, &block)
end
# Compatibility for RFC2396 parser
def make_regexp(schemes = nil) # :nodoc:
warn "Gem::URI::RFC3986_PARSER.make_regexp is obsoleted. Use Gem::URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE
RFC2396_PARSER.make_regexp(schemes)
end
# Compatibility for RFC2396 parser
def escape(str, unsafe = nil) # :nodoc:
warn "Gem::URI::RFC3986_PARSER.escape is obsoleted. Use Gem::URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE
unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str)
end
# Compatibility for RFC2396 parser
def unescape(str, escaped = nil) # :nodoc:
warn "Gem::URI::RFC3986_PARSER.unescape is obsoleted. Use Gem::URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE
escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str)
end
@@to_s = Kernel.instance_method(:to_s)
if @@to_s.respond_to?(:bind_call)
def inspect

View File

@ -1,6 +1,6 @@
module Gem::URI
# :stopdoc:
VERSION_CODE = '001301'.freeze
VERSION_CODE = '010001'.freeze
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
# :startdoc:
end

View File

@ -14,3 +14,4 @@ gem "securerandom", "0.3.1"
gem "timeout", "0.4.1"
gem "thor", "1.3.0"
gem "tsort", "0.2.0"
gem "uri", "1.0.1"