Skip to content

Commit 90dca43

Browse files
menghanldfawley
authored andcommitted
resolver: always fall back to default resolver when target does not follow URI scheme (#1889)
Previously, any target with "://" would be handled according to the URI scheme even though it did not contain a third slash.
1 parent 9aba044 commit 90dca43

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

resolver_conn_wrapper.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ func parseTarget(target string) (ret resolver.Target) {
5454
if !ok {
5555
return resolver.Target{Endpoint: target}
5656
}
57-
ret.Authority, ret.Endpoint, _ = split2(ret.Endpoint, "/")
57+
ret.Authority, ret.Endpoint, ok = split2(ret.Endpoint, "/")
58+
if !ok {
59+
return resolver.Target{Endpoint: target}
60+
}
5861
return ret
5962
}
6063

resolver_conn_wrapper_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func TestParseTargetString(t *testing.T) {
5353
want resolver.Target
5454
}{
5555
{"", resolver.Target{"", "", ""}},
56-
{"://", resolver.Target{"", "", ""}},
5756
{":///", resolver.Target{"", "", ""}},
5857
{"a:///", resolver.Target{"a", "", ""}},
5958
{"://a/", resolver.Target{"", "a", ""}},
@@ -70,6 +69,15 @@ func TestParseTargetString(t *testing.T) {
7069
{"google.com", resolver.Target{"", "", "google.com"}},
7170
{"google.com/?a=b", resolver.Target{"", "", "google.com/?a=b"}},
7271
{"/unix/socket/address", resolver.Target{"", "", "/unix/socket/address"}},
72+
73+
// If we can only parse part of the target.
74+
{"://", resolver.Target{"", "", "://"}},
75+
{"unix://domain", resolver.Target{"", "", "unix://domain"}},
76+
{"a:b", resolver.Target{"", "", "a:b"}},
77+
{"a/b", resolver.Target{"", "", "a/b"}},
78+
{"a:/b", resolver.Target{"", "", "a:/b"}},
79+
{"a//b", resolver.Target{"", "", "a//b"}},
80+
{"a://b", resolver.Target{"", "", "a://b"}},
7381
} {
7482
got := parseTarget(test.targetStr)
7583
if got != test.want {

0 commit comments

Comments
 (0)