Summary Files Commits Branches @commit @diff @stats
path: root / badwolf.c
diff options
context:
space:
mode:
Commit06b34a53c2c7af02fbc673d53b5c13f40c2933a6 (patch)
Author
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2019-12-16 01:47:12 +0100
Committer
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2019-12-16 01:47:12 +0100
Filesf0eb17efd68371a50e2bf670d13cece977b3d7bb /badwolf.c
goodwolf-06b34a53c2c7af02fbc673d53b5c13f40c2933a6.tar
goodwolf-06b34a53c2c7af02fbc673d53b5c13f40c2933a6.tar.gz
goodwolf-06b34a53c2c7af02fbc673d53b5c13f40c2933a6.zip
Parent4e144dd01af4855e02ed394c75e8c04c4dae710b (diff)
Add tests on badwolf_ensure_uri_scheme
1 files changed, 1 insertions, 25 deletions
-rw-r--r--badwolf.c26
diff --git a/badwolf.c b/badwolf.c
index 909df75..627cb3f 100644
--- a/badwolf.c
+++ b/badwolf.c
@@ -6,13 +6,13 @@
#include "config.h"
#include "keybindings.h"
+#include "uri.h"
#include <glib/gi18n.h> /* _() and other internationalization/localization helpers */
#include <glib/gprintf.h> /* g_fprintf() */
#include <libsoup/soup.h> /* soup* */
#include <locale.h> /* LC_* */
#include <stdlib.h> /* malloc() */
-#include <unistd.h> /* access() */
const gchar *homepage = "https://hacktivis.me/projects/badwolf";
const gchar *version = VERSION;
@@ -63,30 +63,6 @@ static void closeCb_clicked(GtkButton *close, gpointer user_data);
static void
notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data);
-const gchar *
-badwolf_ensure_uri_scheme(const gchar *text, gboolean try_file)
-{
- SoupURI *uri = soup_uri_new(text);
-
- if(uri->path == NULL || text == NULL)
- {
- soup_uri_free(uri);
- return "about:blank";
- }
-
- if(uri->scheme != NULL)
- {
- soup_uri_free(uri);
- return text;
- }
-
- soup_uri_free(uri);
-
- if(try_file && (access(text, R_OK) == 0)) return g_strdup_printf("file://%s", text);
-
- return g_strdup_printf("http://%s", text);
-}
-
static gboolean
WebViewCb_close(WebKitWebView *webView, gpointer user_data)
{