]> git.armaanb.net Git - chorizo.git/commitdiff
Automatically add "file://" prefix for local files
authorPeter Hofmann <scm@uninformativ.de>
Fri, 27 Jan 2017 17:36:22 +0000 (18:36 +0100)
committerPeter Hofmann <scm@uninformativ.de>
Fri, 27 Jan 2017 17:38:42 +0000 (18:38 +0100)
Closes #27.

CHANGES
browser.c

diff --git a/CHANGES b/CHANGES
index 4ae5130352a752ff1343b76363455b122f278a25..3714bfe066c0fc3223ac83b27a47fa0325167417 100644 (file)
--- 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]
index 3cf7d608ec55620ada0afaf8ee1a99b5b768554a..d411f6adb46f3b090202e45f9c943b34e0589b91 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -1,3 +1,4 @@
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -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