[gnome-software] trivial: Set the origin correctly for http:/// and file:// URLs
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Set the origin correctly for http:/// and file:// URLs
- Date: Thu, 23 Feb 2017 15:03:15 +0000 (UTC)
commit 7324afb411c6396fc29f80df2e756ba92416bdcd
Author: Richard Hughes <richard hughsie com>
Date: Thu Feb 23 13:15:38 2017 +0000
trivial: Set the origin correctly for http:/// and file:// URLs
src/gs-app.c | 4 ++++
src/gs-self-test.c | 4 +++-
2 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index ae7d464..4c5620c 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -2204,6 +2204,10 @@ gs_app_set_origin_hostname (GsApp *app, const gchar *origin_hostname)
origin_hostname += strlen (prefixes[i]);
}
+ /* fallback for localhost */
+ if (g_strcmp0 (origin_hostname, "") == 0)
+ origin_hostname = "localhost";
+
/* success */
app->origin_hostname = g_strdup (origin_hostname);
}
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 311c144..26dd31c 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -454,6 +454,8 @@ gs_app_func (void)
/* correctly parse URL */
gs_app_set_origin_hostname (app, "https://mirrors.fedoraproject.org/metalink");
g_assert_cmpstr (gs_app_get_origin_hostname (app), ==, "fedoraproject.org");
+ gs_app_set_origin_hostname (app, "file:///home/hughsie");
+ g_assert_cmpstr (gs_app_get_origin_hostname (app), ==, "localhost");
/* check setting the progress */
gs_app_set_progress (app, 42);
@@ -1254,7 +1256,7 @@ gs_plugin_loader_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
GS_APP_KUDO_HI_DPI_ICON |
GS_APP_KUDO_SANDBOXED_SECURE |
GS_APP_KUDO_SANDBOXED);
- g_assert_cmpstr (gs_app_get_origin_hostname (app), ==, "");
+ g_assert_cmpstr (gs_app_get_origin_hostname (app), ==, "localhost");
g_assert_cmpstr (gs_app_get_version (app), ==, "master");
g_assert_cmpstr (gs_app_get_update_version (app), ==, NULL);
g_assert_cmpstr (gs_app_get_update_details (app), ==, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]