Skip to content
Snippets Groups Projects
Unverified Commit 3096823a authored by Koen Zandberg's avatar Koen Zandberg
Browse files

sock_util: Allow URLs without path as valid

URLs without a path were treated as invalid, while according to the URL
specification they are valid

Also fixes a missing null terminator in the returned path
parent 3402e350
No related branches found
No related tags found
No related merge requests found
......@@ -114,7 +114,7 @@ static char* _find_pathstart(const char *url)
}
urlpos++;
}
return NULL;
return urlpos;
}
int sock_urlsplit(const char *url, char *hostport, char *urlpath)
......@@ -125,9 +125,6 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath)
}
char *pathstart = _find_pathstart(hoststart);
if(!pathstart) {
return -EINVAL;
}
memcpy(hostport, hoststart, pathstart - hoststart);
......@@ -135,9 +132,7 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath)
if (pathlen) {
memcpy(urlpath, pathstart, pathlen);
}
else {
*urlpath = '\0';
}
*(urlpath + pathlen) = '\0';
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment