remove registry
'registry' is not used and RFC3986 doesn't use it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b757ff3ef6
commit
c7a7e60409
@ -1,3 +1,8 @@
|
|||||||
|
Sun Jun 22 09:11:15 2014 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/uri/generic.rb: remove registry.
|
||||||
|
'registry' is not used and RFC3986 doesn't use it.
|
||||||
|
|
||||||
Sun Jun 22 09:10:09 2014 NARUSE, Yui <naruse@ruby-lang.org>
|
Sun Jun 22 09:10:09 2014 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* lib/uri/rfc3986_parser.rb: raise exception when given a URI string
|
* lib/uri/rfc3986_parser.rb: raise exception when given a URI string
|
||||||
|
@ -55,16 +55,9 @@ module URI
|
|||||||
self::COMPONENT
|
self::COMPONENT
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
USE_REGISTRY = false # :nodoc:
|
||||||
# Default to not use the registry for a URI::Generic
|
|
||||||
#
|
|
||||||
USE_REGISTRY = false
|
|
||||||
|
|
||||||
#
|
def self.use_registry # :nodoc:
|
||||||
# Returns whether a registry of naming
|
|
||||||
# authorities are being used.
|
|
||||||
#
|
|
||||||
def self.use_registry
|
|
||||||
self::USE_REGISTRY
|
self::USE_REGISTRY
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -185,7 +178,6 @@ module URI
|
|||||||
@path = nil
|
@path = nil
|
||||||
@query = nil
|
@query = nil
|
||||||
@opaque = nil
|
@opaque = nil
|
||||||
@registry = nil
|
|
||||||
@fragment = nil
|
@fragment = nil
|
||||||
@parser = parser == DEFAULT_PARSER ? nil : parser
|
@parser = parser == DEFAULT_PARSER ? nil : parser
|
||||||
|
|
||||||
@ -197,7 +189,6 @@ module URI
|
|||||||
self.path = path
|
self.path = path
|
||||||
self.query = query
|
self.query = query
|
||||||
self.opaque = opaque
|
self.opaque = opaque
|
||||||
self.registry = registry
|
|
||||||
self.fragment = fragment
|
self.fragment = fragment
|
||||||
else
|
else
|
||||||
self.set_scheme(scheme)
|
self.set_scheme(scheme)
|
||||||
@ -207,12 +198,11 @@ module URI
|
|||||||
self.set_path(path)
|
self.set_path(path)
|
||||||
self.set_query(query)
|
self.set_query(query)
|
||||||
self.set_opaque(opaque)
|
self.set_opaque(opaque)
|
||||||
self.set_registry(registry)
|
|
||||||
self.set_fragment(fragment)
|
self.set_fragment(fragment)
|
||||||
end
|
end
|
||||||
if @registry && !self.class.use_registry
|
if registry
|
||||||
raise InvalidURIError,
|
raise InvalidURIError,
|
||||||
"the scheme #{@scheme} does not accept registry part: #{@registry} (or bad hostname?)"
|
"the scheme #{@scheme} does not accept registry part: #{registry} (or bad hostname?)"
|
||||||
end
|
end
|
||||||
|
|
||||||
@scheme.freeze if @scheme
|
@scheme.freeze if @scheme
|
||||||
@ -257,11 +247,9 @@ module URI
|
|||||||
#
|
#
|
||||||
attr_reader :port
|
attr_reader :port
|
||||||
|
|
||||||
# returns the registry component of the URI.
|
def registry # :nodoc:
|
||||||
#
|
nil
|
||||||
# (see RFC2396 Section 3.2)
|
end
|
||||||
#
|
|
||||||
attr_reader :registry
|
|
||||||
|
|
||||||
# returns the path component of the URI.
|
# returns the path component of the URI.
|
||||||
#
|
#
|
||||||
@ -401,9 +389,9 @@ module URI
|
|||||||
# with a user component defined.
|
# with a user component defined.
|
||||||
#
|
#
|
||||||
def check_user(v)
|
def check_user(v)
|
||||||
if @registry || @opaque
|
if @opaque
|
||||||
raise InvalidURIError,
|
raise InvalidURIError,
|
||||||
"can not set user with registry or opaque"
|
"can not set user with opaque"
|
||||||
end
|
end
|
||||||
|
|
||||||
return v unless v
|
return v unless v
|
||||||
@ -425,9 +413,9 @@ module URI
|
|||||||
# with a user component defined.
|
# with a user component defined.
|
||||||
#
|
#
|
||||||
def check_password(v, user = @user)
|
def check_password(v, user = @user)
|
||||||
if @registry || @opaque
|
if @opaque
|
||||||
raise InvalidURIError,
|
raise InvalidURIError,
|
||||||
"can not set password with registry or opaque"
|
"can not set password with opaque"
|
||||||
end
|
end
|
||||||
return v unless v
|
return v unless v
|
||||||
|
|
||||||
@ -598,7 +586,7 @@ module URI
|
|||||||
def check_host(v)
|
def check_host(v)
|
||||||
return v unless v
|
return v unless v
|
||||||
|
|
||||||
if @registry || @opaque
|
if @opaque
|
||||||
raise InvalidURIError,
|
raise InvalidURIError,
|
||||||
"can not set host with registry or opaque"
|
"can not set host with registry or opaque"
|
||||||
elsif parser.regexp[:HOST] !~ v
|
elsif parser.regexp[:HOST] !~ v
|
||||||
@ -690,7 +678,7 @@ module URI
|
|||||||
def check_port(v)
|
def check_port(v)
|
||||||
return v unless v
|
return v unless v
|
||||||
|
|
||||||
if @registry || @opaque
|
if @opaque
|
||||||
raise InvalidURIError,
|
raise InvalidURIError,
|
||||||
"can not set port with registry or opaque"
|
"can not set port with registry or opaque"
|
||||||
elsif !v.kind_of?(Fixnum) && parser.regexp[:PORT] !~ v
|
elsif !v.kind_of?(Fixnum) && parser.regexp[:PORT] !~ v
|
||||||
@ -747,57 +735,18 @@ module URI
|
|||||||
port
|
port
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
def check_registry(v) # :nodoc:
|
||||||
# check the registry +v+ component for RFC2396 compliance
|
raise InvalidURIError, "can not set registry"
|
||||||
# and against the URI::Parser Regexp for :REGISTRY
|
|
||||||
#
|
|
||||||
# Can not have a host, port or user component defined,
|
|
||||||
# with a registry component defined.
|
|
||||||
#
|
|
||||||
def check_registry(v)
|
|
||||||
return v unless v
|
|
||||||
|
|
||||||
# raise if both server and registry are not nil, because:
|
|
||||||
# authority = server | reg_name
|
|
||||||
# server = [ [ userinfo "@" ] hostport ]
|
|
||||||
if @host || @port || @user # userinfo = @user + ':' + @password
|
|
||||||
raise InvalidURIError,
|
|
||||||
"can not set registry with host, port, or userinfo"
|
|
||||||
elsif v && parser.regexp[:REGISTRY] !~ v
|
|
||||||
raise InvalidComponentError,
|
|
||||||
"bad component(expected registry component): #{v}"
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
private :check_registry
|
private :check_registry
|
||||||
|
|
||||||
# protected setter for the registry component +v+
|
def set_registry(v) #:nodoc:
|
||||||
#
|
raise InvalidURIError, "can not set registry"
|
||||||
# see also URI::Generic.registry=
|
|
||||||
#
|
|
||||||
def set_registry(v)
|
|
||||||
@registry = v
|
|
||||||
end
|
end
|
||||||
protected :set_registry
|
protected :set_registry
|
||||||
|
|
||||||
#
|
|
||||||
# == Args
|
|
||||||
#
|
|
||||||
# +v+::
|
|
||||||
# String
|
|
||||||
#
|
|
||||||
# == Description
|
|
||||||
#
|
|
||||||
# public setter for the registry component +v+.
|
|
||||||
# (with validation)
|
|
||||||
#
|
|
||||||
# see also URI::Generic.check_registry
|
|
||||||
#
|
|
||||||
def registry=(v)
|
def registry=(v)
|
||||||
check_registry(v)
|
raise InvalidURIError, "can not set registry"
|
||||||
set_registry(v)
|
|
||||||
v
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -1318,7 +1267,7 @@ module URI
|
|||||||
end
|
end
|
||||||
rel = URI::Generic.new(nil, # it is relative URI
|
rel = URI::Generic.new(nil, # it is relative URI
|
||||||
self.userinfo, self.host, self.port,
|
self.userinfo, self.host, self.port,
|
||||||
self.registry, self.path, self.opaque,
|
nil, self.path, self.opaque,
|
||||||
self.query, self.fragment, parser)
|
self.query, self.fragment, parser)
|
||||||
|
|
||||||
if rel.userinfo != oth.userinfo ||
|
if rel.userinfo != oth.userinfo ||
|
||||||
@ -1461,9 +1410,6 @@ module URI
|
|||||||
if @opaque
|
if @opaque
|
||||||
str << @opaque
|
str << @opaque
|
||||||
|
|
||||||
else
|
|
||||||
if @registry
|
|
||||||
str << @registry
|
|
||||||
else
|
else
|
||||||
if @host
|
if @host
|
||||||
str << '//'
|
str << '//'
|
||||||
@ -1479,7 +1425,6 @@ module URI
|
|||||||
str << ':'
|
str << ':'
|
||||||
str << @port.to_s
|
str << @port.to_s
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
str << path_query
|
str << path_query
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user