diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2014-04-25 15:33:40 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2014-08-25 18:42:06 +0200 |
commit | d54c36cc22c365bd21936365f7c9410899ad3ec1 (patch) | |
tree | a95cc2bdbb456968b5879a883e94e2f1fb732ec4 | |
parent | de21f49cda5554d1395d315c022c2f28d06ba778 (diff) | |
download | librest-d54c36cc22c365bd21936365f7c9410899ad3ec1.tar.gz |
Ignore '/' at beginning of REST function
When building the HTTP URL to access for a REST operation,
RestProxyCall::prepare_message, a '/' at the end of the base URL
is ignored, but a '/' at the beginning of the REST function is not.
When interacting with the oVirt REST API, I often end up building calls
with for example 'https://ovirt.example.com' as the base URI, and '/api/vms/'
as the function, which then leads to an URI with 2 '/':
'https://ovirt.example.com//api/vms'
https://bugzilla.gnome.org/show_bug.cgi?id=728952
-rw-r--r-- | rest/rest-proxy-call.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c index a264f2e..fbf4880 100644 --- a/rest/rest-proxy-call.c +++ b/rest/rest-proxy-call.c @@ -748,7 +748,8 @@ prepare_message (RestProxyCall *call, GError **error_out) /* FIXME: Perhaps excessive memory duplication */ if (priv->function) { - if (g_str_has_suffix (bound_url, "/")) + if (g_str_has_suffix (bound_url, "/") + || g_str_has_prefix (priv->function, "/")) { priv->url = g_strdup_printf ("%s%s", bound_url, priv->function); } else { |