Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolver: always fall back to default resolver when target does not follow URI scheme #1889

Merged
merged 2 commits into from
Mar 8, 2018
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
5 changes: 4 additions & 1 deletion resolver_conn_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ func parseTarget(target string) (ret resolver.Target) {
if !ok {
return resolver.Target{Endpoint: target}
}
ret.Authority, ret.Endpoint, _ = split2(ret.Endpoint, "/")
ret.Authority, ret.Endpoint, ok = split2(ret.Endpoint, "/")
if !ok {
return resolver.Target{Endpoint: target}
}
return ret
}

Expand Down
10 changes: 9 additions & 1 deletion resolver_conn_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func TestParseTargetString(t *testing.T) {
want resolver.Target
}{
{"", resolver.Target{"", "", ""}},
{"://", resolver.Target{"", "", ""}},
{":///", resolver.Target{"", "", ""}},
{"a:///", resolver.Target{"a", "", ""}},
{"://a/", resolver.Target{"", "a", ""}},
Expand All @@ -70,6 +69,15 @@ func TestParseTargetString(t *testing.T) {
{"google.com", resolver.Target{"", "", "google.com"}},
{"google.com/?a=b", resolver.Target{"", "", "google.com/?a=b"}},
{"/unix/socket/address", resolver.Target{"", "", "/unix/socket/address"}},

// If we can only parse part of the target.
{"://", resolver.Target{"", "", "://"}},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth testing other partial matches like "[a]:[b]" and "[a]:/[b]"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{"unix://domain", resolver.Target{"", "", "unix://domain"}},
{"a:b", resolver.Target{"", "", "a:b"}},
{"a/b", resolver.Target{"", "", "a/b"}},
{"a:/b", resolver.Target{"", "", "a:/b"}},
{"a//b", resolver.Target{"", "", "a//b"}},
{"a://b", resolver.Target{"", "", "a://b"}},
} {
got := parseTarget(test.targetStr)
if got != test.want {
Expand Down