From 88b496e1537107361d9aba25b4c54176f13e8ecb Mon Sep 17 00:00:00 2001 From: Peter Hofmann Date: Fri, 27 Jan 2017 18:36:22 +0100 Subject: Automatically add "file://" prefix for local files Closes #27. --- CHANGES | 2 ++ browser.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 4ae5130..3714bfe 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,8 @@ next [Added] - An external user-supplied program can be called for the current URI or for hyperlinks/images/videos/audio files. + - Lariza will now automatically add a "file://" prefix for local + files. v16.12 2016-12-24 [Fixed] diff --git a/browser.c b/browser.c index 3cf7d60..d411f6a 100644 --- a/browser.c +++ b/browser.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -501,7 +502,7 @@ downloadmanager_setup(void) gchar * ensure_uri_scheme(const gchar *t) { - gchar *f; + gchar *f, *fabs; f = g_ascii_strdown(t, -1); if (!g_str_has_prefix(f, "http:") && @@ -510,7 +511,14 @@ ensure_uri_scheme(const gchar *t) !g_str_has_prefix(f, "about:")) { g_free(f); - f = g_strdup_printf("http://%s", t); + fabs = realpath(t, NULL); + if (fabs != NULL) + { + f = g_strdup_printf("file://%s", fabs); + free(fabs); + } + else + f = g_strdup_printf("http://%s", t); return f; } else -- cgit v1.2.3