diff options
| Commit | 59f1c5d4dbcebc48d1d408dba0be2959d7970167 (patch) | |
|---|---|---|
| Author | 2020-02-04 09:14:42 +0100 | |
| Committer | 2020-02-04 09:14:42 +0100 | |
| Files | 98e92b3ace336ba236e9d5e07c15648d070378c0 /uri.c | |
| goodwolf-0.5.0-rc.1.tar goodwolf-0.5.0-rc.1.tar.gz goodwolf-0.5.0-rc.1.zip | ||
| Parent | 9765887719fd5c3f784d30084111243caf90f16f (diff) | |
| Parent | eb974dcccdbcb35fa067ace053bc1fac7406b768 (diff) | |
Merge branch 'release-0.5' v0.5.0-rc.1
1 files changed, 22 insertions, 0 deletions
| -rw-r--r-- | uri.c | 22 |
@@ -0,0 +1,22 @@ +// BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser +// Copyright © 2019-2020 Badwolf Authors <https://hacktivis.me/projects/badwolf> +// SPDX-License-Identifier: BSD-3-Clause + +#include "uri.h" + +#include <glib.h> /* g_strcmp0() */ +#include <unistd.h> /* access() */ + +const gchar * +badwolf_ensure_uri_scheme(const gchar *text, gboolean try_file) +{ + const gchar *fallback = "about:blank"; + + 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); + + return g_strdup_printf("http://%s", text); +} |