Allow about:* urls (#20).
authorDaniel Carl <danielcarl@gmx.de>
Mon, 27 May 2013 18:20:34 +0000 (20:20 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 27 May 2013 18:20:34 +0000 (20:20 +0200)
This was added to have an empty start page. So if the setting 'home-page' is
set to empty ':set home-page=' there is the home-page set to 'about:blank'.

src/main.c
src/setting.c

index 9dcc98f..b7d4fb7 100644 (file)
@@ -124,19 +124,15 @@ gboolean vb_eval_script(WebKitWebFrame *frame, char *script, char *file, char **
 
 gboolean vb_load_uri(const Arg *arg)
 {
-    char *uri = NULL, *rp, *path = arg->s;
+    char *uri = NULL, *rp, *path = arg->s ? arg->s : "";
     struct stat st;
 
-    if (!path) {
-        path = vb.config.home_page;
-    }
-
     g_strstrip(path);
-    if (!strlen(path)) {
+    if (*path == '\0') {
         path = vb.config.home_page;
     }
 
-    if (g_strrstr(path, "://")) {
+    if (g_strrstr(path, "://") || !strncmp(path, "about:", 6)) {
         uri = g_strdup(path);
     } else if (stat(path, &st) == 0) {
         /* check if the path is a file path */
index bc3be88..86a42c1 100644 (file)
@@ -573,7 +573,10 @@ static gboolean home_page(const Setting *s, const SettingType type)
     if (type == SETTING_GET) {
         print_value(s, vb.config.home_page);
     } else {
-        OVERWRITE_STRING(vb.config.home_page, s->arg.s);
+        OVERWRITE_STRING(
+            vb.config.home_page,
+            *(s->arg.s) == '\0' ? "about:blank" : s->arg.s
+        );
     }
 
     return true;