#include "config.h"
#endif
-#define _GNU_SOURCE
#include <assert.h>
-#include <stdbool.h>
#include <string.h>
#include "log/log.h"
return NULL;
}
-static bool is_url(const char *str)
+bool is_url(const char *str)
{
return strstr(str, "://") != NULL;
}
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)
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;