From 2cc226cf1592a60b97217c5938a1b4ddad0fd3b2 Mon Sep 17 00:00:00 2001
From: George Bateman <george.bateman16@gmail.com>
Date: Tue, 12 Jun 2018 15:26:16 +0100
Subject: [PATCH] Detect localhost and IPv6 as valid URLs. Fixes #478.

---
 src/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/main.c b/src/main.c
index 2910f12..0d34ac5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -382,8 +382,11 @@ gboolean vb_load_uri(Client *c, const Arg *arg)
         rp  = realpath(path, NULL);
         uri = g_strconcat("file://", rp, NULL);
         free(rp);
-    } else if (strchr(path, ' ') || !strchr(path, '.')) {
-        /* use a shortcut if path contains spaces or no dot */
+    } else if (strchr(path, ' ') || !(strchr(path, '.') ||
+          (strchr(path, '[') && strchr(path, ':') && strchr(path, ']')) ||
+          strstr(path, "localhost"))) {
+        /* use a shortcut if path contains spaces or doesn't contain typical
+         * characters ('.', [:] for IPv6 addresses, 'localhost') */
         uri = shortcut_get_uri(c->config.shortcuts, path);
     }
 
-- 
2.20.1