Skip to content
Snippets Groups Projects
Commit d423f3c2 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Fix authority in uri_parser

parent 2f89e400
No related branches found
No related tags found
No related merge requests found
...@@ -99,7 +99,7 @@ grpc_uri *grpc_uri_parse(const char *uri_text, int suppress_errors) { ...@@ -99,7 +99,7 @@ grpc_uri *grpc_uri_parse(const char *uri_text, int suppress_errors) {
if (uri_text[scheme_end + 1] == '/' && uri_text[scheme_end + 2] == '/') { if (uri_text[scheme_end + 1] == '/' && uri_text[scheme_end + 2] == '/') {
authority_begin = scheme_end + 3; authority_begin = scheme_end + 3;
for (i = authority_begin; uri_text[i] != 0; i++) { for (i = authority_begin; uri_text[i] != 0; i++) {
if (uri_text[i] == '/') { if (uri_text[i] == '/' && authority_end == -1) {
authority_end = i; authority_end = i;
} }
if (uri_text[i] == '?') { if (uri_text[i] == '?') {
......
...@@ -60,6 +60,7 @@ int main(int argc, char **argv) { ...@@ -60,6 +60,7 @@ int main(int argc, char **argv) {
test_succeeds("http://www.google.com:90", "http", "www.google.com:90", ""); test_succeeds("http://www.google.com:90", "http", "www.google.com:90", "");
test_succeeds("a192.4-df:foo.coom", "a192.4-df", "", "foo.coom"); test_succeeds("a192.4-df:foo.coom", "a192.4-df", "", "foo.coom");
test_succeeds("a+b:foo.coom", "a+b", "", "foo.coom"); test_succeeds("a+b:foo.coom", "a+b", "", "foo.coom");
test_succeeds("zookeeper://127.0.0.1:2181/foo/bar", "zookeeper", "127.0.0.1:2181", "/foo/bar");
test_fails("xyz"); test_fails("xyz");
test_fails("http://www.google.com?why-are-you-using-queries"); test_fails("http://www.google.com?why-are-you-using-queries");
test_fails("dns:foo.com#fragments-arent-supported-here"); test_fails("dns:foo.com#fragments-arent-supported-here");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment