]> git.ozlabs.org Git - petitboot/blobdiff - ui/common/url.c
discover-client: interact directly with waitset
[petitboot] / ui / common / url.c
index 3e7b3840803e545e3ae35971beed8e9f0151c36f..4e4b9610cd96f1016a6d38aca78e258f5a97452c 100644 (file)
@@ -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;
+}