diff options
author | Christoph Lohmann <20h@r-36.net> | 2012-11-25 22:31:46 +0100 |
---|---|---|
committer | Christoph Lohmann <20h@r-36.net> | 2012-11-25 22:31:46 +0100 |
commit | 6cd54e4a3119bd201d95f5d67ffb4bfe28aac653 (patch) | |
tree | 6f36762e081398e5a30ce72020590e131bb86da1 /surf.c | |
parent | ad794e0f00f56065f4e8d7e4cd1e4b8873938993 (diff) | |
download | surf-6cd54e4a3119bd201d95f5d67ffb4bfe28aac653.tar.gz surf-6cd54e4a3119bd201d95f5d67ffb4bfe28aac653.tar.bz2 surf-6cd54e4a3119bd201d95f5d67ffb4bfe28aac653.zip |
Surf now can handle absolute file paths. This allows better local HTML
reading.
Diffstat (limited to 'surf.c')
-rw-r--r-- | surf.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -13,6 +13,7 @@ #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> +#include <limits.h> #include <stdlib.h> #include <stdio.h> #include <webkit/webkit.h> @@ -497,14 +498,23 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) { void loaduri(Client *c, const Arg *arg) { - char *u; + char *u, *rp; const char *uri = (char *)arg->v; Arg a = { .b = FALSE }; if(strcmp(uri, "") == 0) return; - u = g_strrstr(uri, "://") ? g_strdup(uri) - : g_strdup_printf("http://%s", uri); + + /* In case it's a file path. */ + if(uri[0] == '/') { + rp = realpath(uri, NULL); + u = g_strdup_printf("file://%s", rp); + free(rp); + } else { + u = g_strrstr(uri, "://") ? g_strdup(uri) + : g_strdup_printf("http://%s", uri); + } + /* prevents endless loop */ if(c->uri && strcmp(u, c->uri) == 0) { reload(c, &a); |