diff options
author | Peter Hofmann <scm@uninformativ.de> | 2017-01-27 18:36:22 +0100 |
---|---|---|
committer | Peter Hofmann <scm@uninformativ.de> | 2017-01-27 18:38:42 +0100 |
commit | 88b496e1537107361d9aba25b4c54176f13e8ecb (patch) | |
tree | 554647ba23c9b85cfd010bb61eee28db9b287fee | |
parent | 82d5f9e1d3c296512aa5a1dacd9036f2a3857fd8 (diff) | |
download | lariza-88b496e1537107361d9aba25b4c54176f13e8ecb.tar.gz |
Automatically add "file://" prefix for local files
Closes #27.
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | browser.c | 12 |
2 files changed, 12 insertions, 2 deletions
@@ -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] @@ -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 |