Bug #11759 » 0001-Do-not-mutate-strings-in-URI-to_s.patch
lib/uri/generic.rb | ||
---|---|---|
#
|
||
def to_s
|
||
str = ''
|
||
if @scheme
|
||
str << @scheme
|
||
str << ':'.freeze
|
||
str = "#{str}#{@scheme}:"
|
||
end
|
||
if @opaque
|
||
str << @opaque
|
||
str = "#{str}#{@opaque}"
|
||
else
|
||
if @host
|
||
str << '//'.freeze
|
||
str = "#{str}//"
|
||
end
|
||
if self.userinfo
|
||
str << self.userinfo
|
||
str << '@'.freeze
|
||
str = "#{str}#{self.userinfo}@"
|
||
end
|
||
if @host
|
||
str << @host
|
||
str = "#{str}#{@host}"
|
||
end
|
||
if @port && @port != self.default_port
|
||
str << ':'.freeze
|
||
str << @port.to_s
|
||
str = "#{str}:#{@port}"
|
||
end
|
||
str << @path
|
||
str = "#{str}#{@path}"
|
||
if @query
|
||
str << '?'.freeze
|
||
str << @query
|
||
str = "#{str}?#{@query}"
|
||
end
|
||
end
|
||
if @fragment
|
||
str << '#'.freeze
|
||
str << @fragment
|
||
str = "#{str}##{@fragment}"
|
||
end
|
||
str
|
||
end
|