This patch allows to specify a relative filename, and only
prepends 'file://' when it actually exists.

commit b8f02a8af106afc19d80ffb3c6e4be69fb7e2609
Author: Kurt Van Dijck <k...@vandijck-laurijssen.be>
Date:   Thu Mar 14 11:45:34 2013

    treat uri as file when it exists
    
    Signed-off-by: Kurt Van Dijck <k...@vandijck-laurijssen.be>

diff --git a/surf.c b/surf.c
index 830665a..ac8d948 100644
--- a/surf.c
+++ b/surf.c
@@ -577,12 +577,13 @@ loaduri(Client *c, const Arg *arg) {
        char *u, *rp;
        const char *uri = (char *)arg->v;
        Arg a = { .b = FALSE };
+       struct stat st;
 
        if(strcmp(uri, "") == 0)
                return;
 
        /* In case it's a file path. */
-       if(uri[0] == '/') {
+       if (stat(uri, &st) == 0) {
                rp = realpath(uri, NULL);
                u = g_strdup_printf("file://%s", rp);
                free(rp);

Reply via email to