summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorJuan A. Suarez Romero <jasuarez@igalia.com>2013-09-08 13:57:53 +0200
committerJuan A. Suarez Romero <jasuarez@igalia.com>2013-09-08 13:59:21 +0200
commit2ae4708a521d550376169cf2dde37636a02599d1 (patch)
treeb3477f5220996e538ba84eff179b5c95934c0f49 /libs
parent3c0237a858e445e215d5e6766ff519614b039c8b (diff)
downloadgrilo-2ae4708a521d550376169cf2dde37636a02599d1.tar.gz
net: Check if URL has query parameters
When using the GrlNet mock, we could need to skip some of the query parameters in the URL. This commit cover the case of having an URL without any query parameter. https://bugzilla.gnome.org/show_bug.cgi?id=706805
Diffstat (limited to 'libs')
-rw-r--r--libs/net/grl-net-mock.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/libs/net/grl-net-mock.c b/libs/net/grl-net-mock.c
index 6541947..184af68 100644
--- a/libs/net/grl-net-mock.c
+++ b/libs/net/grl-net-mock.c
@@ -61,13 +61,18 @@ get_url_mocked (GrlNetWc *self,
if (ignored_parameters) {
SoupURI *uri = soup_uri_new (url);
- char *new_query = g_regex_replace (ignored_parameters,
- soup_uri_get_query (uri), -1, 0,
- "", 0, NULL);
- soup_uri_set_query (uri, *new_query ? new_query : NULL);
- new_url = soup_uri_to_string (uri, FALSE);
- soup_uri_free (uri);
- g_free (new_query);
+ const char *query = soup_uri_get_query (uri);
+ if (query) {
+ char *new_query = g_regex_replace (ignored_parameters,
+ query, -1, 0,
+ "", 0, NULL);
+ soup_uri_set_query (uri, *new_query ? new_query : NULL);
+ new_url = soup_uri_to_string (uri, FALSE);
+ soup_uri_free (uri);
+ g_free (new_query);
+ } else {
+ new_url = g_strdup (url);
+ }
} else {
new_url = g_strdup (url);
}