Skip to content

Commit 4724c1b

Browse files
committed
Support IPv6 URLs
Fix: #1100
1 parent 59a2102 commit 4724c1b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22

3+
* Support IPv6 URLs.
34
* Add `Redis#with` for better compatibility with `connection_pool` usage.
45
* Fix the block form of `multi` called inside `pipelined`. Previously the `MUTLI/EXEC` wouldn't be sent. See #1073.
56

lib/redis/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ def _parse_options(options)
464464
defaults[:path] = uri.path
465465
when "redis", "rediss"
466466
defaults[:scheme] = uri.scheme
467-
defaults[:host] = uri.host if uri.host
467+
defaults[:host] = uri.host.sub(/\A\[(.*)\]\z/, '\1') if uri.host
468468
defaults[:port] = uri.port if uri.port
469469
defaults[:username] = CGI.unescape(uri.user) if uri.user && !uri.user.empty?
470470
defaults[:password] = CGI.unescape(uri.password) if uri.password && !uri.password.empty?

test/url_param_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ def test_defaults_to_localhost
135135
assert_equal "127.0.0.1", redis._client.host
136136
end
137137

138+
def test_ipv6_url
139+
redis = Redis.new url: "redis://[::1]"
140+
141+
assert_equal "::1", redis._client.host
142+
end
143+
138144
def test_user_and_password
139145
redis = Redis.new(url: 'redis://johndoe:[email protected]:999/2')
140146

0 commit comments

Comments
 (0)