Bug #19266 ยป 0001-Update-URI-Generic.build-build2-to-use-RFC3986_PARSE.patch
lib/uri/generic.rb | ||
---|---|---|
# +fragment+::
|
||
# Part of the URI after '#' character.
|
||
# +parser+::
|
||
# Parser for internal use [URI::DEFAULT_PARSER by default].
|
||
# Parser for internal use [URI::RFC3986_PARSER by default].
|
||
# +arg_check+::
|
||
# Check arguments [false by default].
|
||
#
|
||
... | ... | |
path, opaque,
|
||
query,
|
||
fragment,
|
||
parser = DEFAULT_PARSER,
|
||
parser = RFC3986_PARSER,
|
||
arg_check = false)
|
||
@scheme = nil
|
||
@user = nil
|
||
... | ... | |
@query = nil
|
||
@opaque = nil
|
||
@fragment = nil
|
||
@parser = parser == DEFAULT_PARSER ? nil : parser
|
||
@parser = parser == RFC3986_PARSER ? nil : parser
|
||
if arg_check
|
||
self.scheme = scheme
|
||
... | ... | |
# Returns the parser to be used.
|
||
#
|
||
# Unless a URI::Parser is defined, DEFAULT_PARSER is used.
|
||
# Unless a URI::Parser is defined, RFC3986_PARSER is used.
|
||
#
|
||
def parser
|
||
if !defined?(@parser) || !@parser
|
||
DEFAULT_PARSER
|
||
RFC3986_PARSER
|
||
else
|
||
@parser || DEFAULT_PARSER
|
||
@parser || RFC3986_PARSER
|
||
end
|
||
end
|
||
test/uri/test_generic.rb | ||
---|---|---|
assert_equal(":5432", u.to_s)
|
||
assert_equal(5432, u.port)
|
||
u = URI::Generic.build(:host => "underscore_host.test")
|
||
assert_equal("//underscore_host.test", u.to_s)
|
||
assert_equal("underscore_host.test", u.host)
|
||
u = URI::Generic.build(:scheme => "http", :host => "::1", :path => "/bar/baz")
|
||
assert_equal("http://[::1]/bar/baz", u.to_s)
|
||
assert_equal("[::1]", u.host)
|