[grilo] net: Check if URL has query parameters



commit 2ae4708a521d550376169cf2dde37636a02599d1
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Sun Sep 8 13:57:53 2013 +0200

    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

 libs/net/grl-net-mock.c |   19 ++++++++++++-------
 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);
   }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]