We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 88eeea8 commit b3a035fCopy full SHA for b3a035f
lib/uri/generic.rb
@@ -643,7 +643,7 @@ def host=(v)
643
#
644
def hostname
645
v = self.host
646
- /\A\[(.*)\]\z/ =~ v ? $1 : v
+ v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v
647
end
648
649
# Sets the host part of the URI as the argument with brackets for IPv6 addresses.
@@ -659,7 +659,7 @@ def hostname
659
# it is wrapped with brackets.
660
661
def hostname=(v)
662
- v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v
+ v = "[#{v}]" if v&.index(':') && !v.start_with?('[') && !v.end_with?(']')
663
self.host = v
664
665
0 commit comments