remove redundant leading slashes from repository path when parsing URIs
diff --git a/lib/fetch.c b/lib/fetch.c
index b30b0e0..bb30d57 100644
--- a/lib/fetch.c
+++ b/lib/fetch.c
@@ -305,6 +305,8 @@ got_fetch_parse_uri(char **proto, char **host, char **port,
}
}
+ while (p[0] == '/' && p[1] == '/')
+ p++;
*server_path = strdup(p);
if (*server_path == NULL) {
err = got_error_from_errno("strdup");
diff --git a/regress/fetch/fetch_test.c b/regress/fetch/fetch_test.c
index 8f65621..f8fea68 100644
--- a/regress/fetch/fetch_test.c
+++ b/regress/fetch/fetch_test.c
@@ -86,6 +86,12 @@ fetch_parse_uri(void)
{ "git://127.0.0.1/git/myrepo",
"git", "127.0.0.1", NULL,
"/git/myrepo", "myrepo", GOT_ERR_OK },
+ { "git://127.0.0.1//git/myrepo",
+ "git", "127.0.0.1", NULL,
+ "/git/myrepo", "myrepo", GOT_ERR_OK },
+ { "git://127.0.0.1/////git//myrepo",
+ "git", "127.0.0.1", NULL,
+ "/git//myrepo", "myrepo", GOT_ERR_OK },
{ "http://127.0.0.1/git/myrepo",
"http", "127.0.0.1", NULL,
"/git/myrepo", "myrepo", GOT_ERR_OK },