[gnome-software/wip/ubuntu-3-22: 7/14] Handle apt URLs of the form apt://packagename



commit b3c64e00c7f3138db53c95a26bc0723e4ef3a423
Author: Robert Ancell <robert ancell canonical com>
Date:   Thu Feb 2 14:22:52 2017 +1300

    Handle apt URLs of the form apt://packagename

 src/gs-application.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 8d170b8..e66042d 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -965,12 +965,18 @@ gs_application_open (GApplication  *application,
                                                        g_variant_new ("(ss)", path, ""));
                }
                if (g_strcmp0 (soup_uri_get_scheme (uri), "apt") == 0) {
+                       const gchar *host = soup_uri_get_host (uri);
                        const gchar *path = soup_uri_get_path (uri);
 
                        /* trim any leading slashes */
                        while (*path == '/')
                                path++;
 
+                       /* apt://foo -> scheme: apt, host: foo, path: / */
+                       /* apt:foo -> scheme: apt, host: (empty string), path: /foo */
+                       if (host != NULL && (strlen (host) > 0))
+                               path = host;
+
                        g_action_group_activate_action (G_ACTION_GROUP (app),
                                                        "details-pkg",
                                                        g_variant_new_string (path));


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