diff --git a/mongo/address/addr.go b/mongo/address/addr.go index fb6abbcd7c..85cf12067c 100644 --- a/mongo/address/addr.go +++ b/mongo/address/addr.go @@ -29,8 +29,11 @@ func (a Address) Network() string { // String is the canonical version of this address, e.g. localhost:27017, // 1.2.3.4:27017, example.com:27017. func (a Address) String() string { - // TODO: unicode case folding? - s := strings.ToLower(string(a)) + s := string(a) + if a.Network() != "unix" { + // TODO: unicode case folding? + s = strings.ToLower(string(a)) + } if len(s) == 0 { return "" } diff --git a/mongo/address/addr_test.go b/mongo/address/addr_test.go index 2242b6d49c..0e2f474ce1 100644 --- a/mongo/address/addr_test.go +++ b/mongo/address/addr_test.go @@ -22,6 +22,7 @@ func TestAddress_String(t *testing.T) { {"A:27017", "a:27017"}, {"a:27017", "a:27017"}, {"a.sock", "a.sock"}, + {"A.sock", "A.sock"}, } for _, test := range tests { diff --git a/testdata/connection-string/valid-unix_socket-absolute.json b/testdata/connection-string/valid-unix_socket-absolute.json index 5bb02476eb..66491db13b 100644 --- a/testdata/connection-string/valid-unix_socket-absolute.json +++ b/testdata/connection-string/valid-unix_socket-absolute.json @@ -30,6 +30,21 @@ "auth": null, "options": null }, + { + "description": "Unix domain socket (mixed case)", + "uri": "mongodb://%2Ftmp%2FMongoDB-27017.sock", + "valid": true, + "warning": false, + "hosts": [ + { + "type": "unix", + "host": "/tmp/MongoDB-27017.sock", + "port": null + } + ], + "auth": null, + "options": null + }, { "description": "Unix domain socket (absolute path with spaces in path)", "uri": "mongodb://%2Ftmp%2F %2Fmongodb-27017.sock", diff --git a/testdata/connection-string/valid-unix_socket-absolute.yml b/testdata/connection-string/valid-unix_socket-absolute.yml index 651e06fe39..cdfd00d332 100644 --- a/testdata/connection-string/valid-unix_socket-absolute.yml +++ b/testdata/connection-string/valid-unix_socket-absolute.yml @@ -23,6 +23,18 @@ tests: port: ~ auth: ~ options: ~ + - + description: "Unix domain socket (mixed case)" + uri: "mongodb://%2Ftmp%2FMongoDB-27017.sock" + valid: true + warning: false + hosts: + - + type: "unix" + host: "/tmp/MongoDB-27017.sock" + port: ~ + auth: ~ + options: ~ - description: "Unix domain socket (absolute path with spaces in path)" uri: "mongodb://%2Ftmp%2F %2Fmongodb-27017.sock" diff --git a/testdata/connection-string/valid-unix_socket-relative.json b/testdata/connection-string/valid-unix_socket-relative.json index 2ce649ffc2..788720920b 100644 --- a/testdata/connection-string/valid-unix_socket-relative.json +++ b/testdata/connection-string/valid-unix_socket-relative.json @@ -30,6 +30,21 @@ "auth": null, "options": null }, + { + "description": "Unix domain socket (mixed case)", + "uri": "mongodb://rel%2FMongoDB-27017.sock", + "valid": true, + "warning": false, + "hosts": [ + { + "type": "unix", + "host": "rel/MongoDB-27017.sock", + "port": null + } + ], + "auth": null, + "options": null + }, { "description": "Unix domain socket (relative path with spaces)", "uri": "mongodb://rel%2F %2Fmongodb-27017.sock", diff --git a/testdata/connection-string/valid-unix_socket-relative.yml b/testdata/connection-string/valid-unix_socket-relative.yml index 7164188b3b..6d0d108205 100644 --- a/testdata/connection-string/valid-unix_socket-relative.yml +++ b/testdata/connection-string/valid-unix_socket-relative.yml @@ -23,6 +23,18 @@ tests: port: ~ auth: ~ options: ~ + - + description: "Unix domain socket (mixed case)" + uri: "mongodb://rel%2FMongoDB-27017.sock" + valid: true + warning: false + hosts: + - + type: "unix" + host: "rel/MongoDB-27017.sock" + port: ~ + auth: ~ + options: ~ - description: "Unix domain socket (relative path with spaces)" uri: "mongodb://rel%2F %2Fmongodb-27017.sock"