X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=ui%2Fcommon%2Furl.c;h=4e4b9610cd96f1016a6d38aca78e258f5a97452c;hp=3e7b3840803e545e3ae35971beed8e9f0151c36f;hb=1b0b59295d0500764c5096753f7cd11bf3ab5df4;hpb=e01ca9726e5ce96605cb57595999885fde18884b diff --git a/ui/common/url.c b/ui/common/url.c index 3e7b384..4e4b961 100644 --- a/ui/common/url.c +++ b/ui/common/url.c @@ -170,6 +170,11 @@ struct pb_url *pb_url_parse(void *ctx, const char *url_str) url->port = NULL; url->host = talloc_strndup(url, p, path - p); } + + /* remove multiple leading slashes */ + for (; *path && *(path+1) == '/'; path++) + ; + url->path = talloc_strdup(url, path); } @@ -197,3 +202,14 @@ fail: talloc_free(url); return NULL; } + +const char *pb_url_scheme_name(enum pb_url_scheme scheme) +{ + unsigned int i; + + for (i = 0; i < sizeof(schemes) / sizeof(schemes[0]); i++) + if (schemes[i].scheme == scheme) + return schemes[i].str; + + return NULL; +}