aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-embed-utils.c
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gns@gnome.org>2012-03-11 03:52:04 +0800
committerGustavo Noronha Silva <gns@gnome.org>2012-03-14 23:28:26 +0800
commit398e670b1dd80cd0427a1db8a21dfc892bbe5eaf (patch)
tree27d409b421f85736d88fe27f6b05853e3fb12054 /embed/ephy-embed-utils.c
parent0ea81088cf97aee3d5bbb1f0ec470b8c805a746d (diff)
downloadgsoc2013-epiphany-398e670b1dd80cd0427a1db8a21dfc892bbe5eaf.tar.gz
gsoc2013-epiphany-398e670b1dd80cd0427a1db8a21dfc892bbe5eaf.tar.zst
gsoc2013-epiphany-398e670b1dd80cd0427a1db8a21dfc892bbe5eaf.zip
Automatically prefix existing absolute paths with file://
https://bugzilla.gnome.org/show_bug.cgi?id=671792
Diffstat (limited to 'embed/ephy-embed-utils.c')
-rw-r--r--embed/ephy-embed-utils.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index e01842496..70c8a6c03 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -103,6 +103,13 @@ ephy_embed_utils_address_has_web_scheme (const char *address)
return has_web_scheme;
}
+gboolean
+ephy_embed_utils_address_is_existing_absolute_filename (const char *address)
+{
+ return g_path_is_absolute (address) &&
+ g_file_test (address, G_FILE_TEST_EXISTS);
+}
+
char*
ephy_embed_utils_normalize_address (const char *address)
{
@@ -111,6 +118,9 @@ ephy_embed_utils_normalize_address (const char *address)
g_return_val_if_fail (address, NULL);
+ if (ephy_embed_utils_address_is_existing_absolute_filename (address))
+ return g_strconcat ("file://", address, NULL);
+
uri = soup_uri_new (address);
/* FIXME: if we are here we passed through the "should we
@@ -123,7 +133,7 @@ ephy_embed_utils_normalize_address (const char *address)
* being the port. Ideally we should check if we have a
* handler for the scheme, and since we'll fail for localhost
* and IP, we'd fallback to loading it as a domain. */
- if (!uri ||
+ if (!uri ||
(uri && !g_strcmp0 (uri->scheme, "localhost")) ||
(uri && g_hostname_is_ip_address (uri->scheme)))
effective_address = g_strconcat ("http://", address, NULL);