diff options
Add tests on badwolf_ensure_uri_scheme
1 files changed, 1 insertions, 25 deletions
| -rw-r--r-- | badwolf.c | 26 |
@@ -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) { |