Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions redis/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ func DialURLContext(ctx context.Context, rawurl string, options ...DialOption) (
return nil, err
}

if u.Scheme != "redis" && u.Scheme != "rediss" {
switch u.Scheme {
case "redis", "rediss", "valkey", "valkeys":
// valid scheme
default:
return nil, fmt.Errorf("invalid redis URL scheme: %s", u.Scheme)
}

Expand Down Expand Up @@ -386,7 +389,7 @@ func DialURLContext(ctx context.Context, rawurl string, options ...DialOption) (
return nil, fmt.Errorf("invalid database: %s", u.Path[1:])
}

options = append(options, DialUseTLS(u.Scheme == "rediss"))
options = append(options, DialUseTLS(u.Scheme == "rediss" || u.Scheme == "valkeys"))

return DialContext(ctx, "tcp", address, options...)
}
Expand Down
16 changes: 16 additions & 0 deletions redis/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,22 @@ var dialErrors = []struct {
"redis:foo//localhost:6379",
"invalid redis URL, url is opaque: redis:foo//localhost:6379",
},
{
"valkey://localhost:6379/abc123",
"invalid database: abc123",
},
{
"valkeys://localhost:6379/abc123",
"invalid database: abc123",
},
{
"valkey:foo//localhost:6379",
"invalid redis URL, url is opaque: valkey:foo//localhost:6379",
},
{
"valkeys:foo//localhost:6379",
"invalid redis URL, url is opaque: valkeys:foo//localhost:6379",
},
}

func TestDialURLErrors(t *testing.T) {
Expand Down
Loading