Summary Files Commits Branches @commit @diff @stats
path: root / uri.c
diff options
context:
space:
mode:
1 files changed, 18 insertions, 1 deletions
-rw-r--r--uri.c19
diff --git a/uri.c b/uri.c
index 6843e4a..59e50d7 100644
--- a/uri.c
+++ b/uri.c
@@ -11,12 +11,29 @@ const gchar *
badwolf_ensure_uri_scheme(const gchar *text, gboolean try_file)
{
const gchar *fallback = "about:blank";
+ char *path = NULL;
if(g_strcmp0(text, "") <= 0) return fallback;
if(g_uri_parse_scheme(text)) return text;
- if(try_file && (access(text, R_OK) == 0)) return g_strdup_printf("file://%s", text);
+ if(try_file)
+ {
+ path = realpath(text, NULL);
+ gchar *f = NULL;
+
+ if(path != NULL)
+ {
+ if(access(path, R_OK) == 0)
+ {
+ f = g_strdup_printf("file://%s", path);
+ }
+
+ free(path);
+
+ return f;
+ }
+ }
return g_strdup_printf("http://%s", text);
}