summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/spice-proxy.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gtk/spice-proxy.c b/gtk/spice-proxy.c
index 55c9023..bc4037e 100644
--- a/gtk/spice-proxy.c
+++ b/gtk/spice-proxy.c
@@ -48,18 +48,29 @@ SpiceProxy* spice_proxy_new(void)
}
G_GNUC_INTERNAL
-gboolean spice_proxy_parse(SpiceProxy *self, const gchar *uri, GError **error)
+gboolean spice_proxy_parse(SpiceProxy *self, const gchar *proxyuri, GError **error)
{
+ gchar *dup, *uri;
gboolean success = FALSE;
+ size_t len;
g_return_val_if_fail(self != NULL, FALSE);
- g_return_val_if_fail(uri != NULL, FALSE);
+ g_return_val_if_fail(proxyuri != NULL, FALSE);
+ uri = dup = g_strdup(proxyuri);
/* FIXME: use GUri when it is ready... only support http atm */
/* the code is voluntarily not parsing thoroughly the uri */
if (g_ascii_strncasecmp("http://", uri, 7) == 0)
uri += 7;
+ /* remove trailing slash */
+ len = strlen(uri);
+ for (; len > 0; len--)
+ if (uri[len-1] == '/')
+ uri[len-1] = '\0';
+ else
+ break;
+
spice_proxy_set_protocol(self, "http");
spice_proxy_set_port(self, 3128);
@@ -90,6 +101,7 @@ gboolean spice_proxy_parse(SpiceProxy *self, const gchar *uri, GError **error)
success = TRUE;
end:
+ g_free(dup);
g_strfreev(proxyv);
return success;
}