summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/url/url.c13
-rw-r--r--lib/url/url.h1
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/url/url.c b/lib/url/url.c
index 1e69774..42bd4a1 100644
--- a/lib/url/url.c
+++ b/lib/url/url.c
@@ -242,18 +242,21 @@ static bool is_url(const char *str)
return strstr(str, "://") != NULL;
}
-static void pb_url_update_full(struct pb_url *url)
+char *pb_url_to_string(struct pb_url *url)
{
const struct pb_scheme_info *scheme = pb_url_scheme_info(url->scheme);
-
assert(scheme);
- talloc_free(url->full);
-
- url->full = talloc_asprintf(url, "%s://%s%s", scheme->str,
+ return talloc_asprintf(url, "%s://%s%s", scheme->str,
scheme->has_host ? url->host : "", url->path);
}
+static void pb_url_update_full(struct pb_url *url)
+{
+ talloc_free(url->full);
+ url->full = pb_url_to_string(url);
+}
+
static struct pb_url *pb_url_copy(void *ctx, const struct pb_url *url)
{
struct pb_url *new_url;
diff --git a/lib/url/url.h b/lib/url/url.h
index 40c1164..997cdcb 100644
--- a/lib/url/url.h
+++ b/lib/url/url.h
@@ -60,6 +60,7 @@ struct pb_url {
struct pb_url *pb_url_parse(void *ctx, const char *url_str);
struct pb_url *pb_url_join(void *ctx, const struct pb_url *url, const char *s);
+char *pb_url_to_string(struct pb_url *url);
const char *pb_url_scheme_name(enum pb_url_scheme scheme);
OpenPOWER on IntegriCloud