Summary Files Commits Branches @commit @diff @stats
path: root / uri.c
diff options
context:
space:
mode:
Commitacde5dfc614ee549b5c1f0119c7e3c8c777c4a82 (patch)
Author
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-07-08 07:42:06 +0200
Committer
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-07-08 07:42:06 +0200
Files7a84d999ef7e84a8dc40293f7affb068ba01a2b6 /uri.c
goodwolf-1.0.1.tar
goodwolf-1.0.1.tar.gz
goodwolf-1.0.1.zip
Parenta49df8ad9869a47a10138738b38fd0ffdb95e402 (diff)
Parentdf18b8d0a3a0634e18b518e9cfc21fd8f4ea7908 (diff)
Merge branch 'release-1.0' into missy for 1.0.1 v1.0.1
Fixes ------- - Support for relative paths as command line arguments - Downloads tab: no longer resizes the main window - Manpage: Syntax is now correct, unbreaking GNU groff formatting. Changes ------- - When an user requests as new tab (ctrl-t, new tab button), switch to it - Downloads tab: A scrollable list view is used instead of a stack of labels
1 files changed, 20 insertions, 2 deletions
-rw-r--r--uri.c22
diff --git a/uri.c b/uri.c
index 6843e4a..912bf86 100644
--- a/uri.c
+++ b/uri.c
@@ -4,19 +4,37 @@
#include "uri.h"
-#include <glib.h> /* g_strcmp0() */
+#include <glib.h> /* g_strcmp0(), g_uri_parse_scheme(), g_strdup_printf */
+#include <stdlib.h> /* realpath(), free() */
#include <unistd.h> /* access() */
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);
}