diff options
author | Lukas Zapletal <lzap+git@redhat.com> | 2020-10-07 13:23:00 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-04-22 14:54:28 +0900 |
commit | c46a4b8c7f434110c30c9587e02387283076579f (patch) | |
tree | 199455a0beb1a153a8bea9e1bf4f3081b192d51a /lib | |
parent | 6e06c980dace26ff2f06eb4ac1e2d06291101ee7 (diff) |
[ruby/uri] Optimize URI#hostname and URI#hostname=
https://github.com/ruby/uri/commit/3b7ccfd835
Diffstat (limited to 'lib')
-rw-r--r-- | lib/uri/generic.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 7de62b66db..cfa0de6b74 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -643,7 +643,7 @@ module URI # def hostname v = self.host - /\A\[(.*)\]\z/ =~ v ? $1 : v + v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v end # Sets the host part of the URI as the argument with brackets for IPv6 addresses. @@ -659,7 +659,7 @@ module URI # it is wrapped with brackets. # def hostname=(v) - v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v + v = "[#{v}]" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':') self.host = v end |