X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=lib%2Furl%2Furl.c;h=a2ca3a58d4a4273016012b351d228b18154208a3;hb=47038255f6ec971e8273c441066f8b1cba3380b7;hp=7202f4965414be300cd9e1c5cb0ee8ea68c3c29b;hpb=66bf929fa97fabb70198455f9eec2e9ccf0661fa;p=petitboot diff --git a/lib/url/url.c b/lib/url/url.c index 7202f49..a2ca3a5 100644 --- a/lib/url/url.c +++ b/lib/url/url.c @@ -234,10 +234,17 @@ bool is_url(const char *str) char *pb_url_to_string(struct pb_url *url) { const struct pb_scheme_info *scheme = pb_url_scheme_info(url->scheme); + char *str, *port; assert(scheme); - return talloc_asprintf(url, "%s://%s%s", scheme->str, - scheme->has_host ? url->host : "", url->path); + port = url->port ? talloc_asprintf(url, ":%s", url->port) : NULL; + + str = talloc_asprintf(url, "%s://%s%s%s", scheme->str, + scheme->has_host ? url->host : "", + port ?: "", url->path); + + talloc_free(port); + return str; } static void pb_url_update_full(struct pb_url *url) @@ -246,7 +253,7 @@ static void pb_url_update_full(struct pb_url *url) url->full = pb_url_to_string(url); } -static struct pb_url *pb_url_copy(void *ctx, const struct pb_url *url) +struct pb_url *pb_url_copy(void *ctx, const struct pb_url *url) { struct pb_url *new_url;