Skip to content

Commit

Permalink
Support IPv6 URLs
Browse files Browse the repository at this point in the history
Fix: #1100
  • Loading branch information
byroot committed May 21, 2022
1 parent 59a2102 commit 4724c1b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

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

Expand Down
2 changes: 1 addition & 1 deletion lib/redis/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def _parse_options(options)
defaults[:path] = uri.path
when "redis", "rediss"
defaults[:scheme] = uri.scheme
defaults[:host] = uri.host if uri.host
defaults[:host] = uri.host.sub(/\A\[(.*)\]\z/, '\1') if uri.host
defaults[:port] = uri.port if uri.port
defaults[:username] = CGI.unescape(uri.user) if uri.user && !uri.user.empty?
defaults[:password] = CGI.unescape(uri.password) if uri.password && !uri.password.empty?
Expand Down
6 changes: 6 additions & 0 deletions test/url_param_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ def test_defaults_to_localhost
assert_equal "127.0.0.1", redis._client.host
end

def test_ipv6_url
redis = Redis.new url: "redis://[::1]"

assert_equal "::1", redis._client.host
end

def test_user_and_password
redis = Redis.new(url: 'redis://johndoe:[email protected]:999/2')

Expand Down

0 comments on commit 4724c1b

Please sign in to comment.