diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index ad78388..5729ac1 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -158,7 +158,9 @@ static guint signals[LAST_SIGNAL];
 #define USERCHARS_CLASS "[" USERCHARS "]"
 #define PASSCHARS_CLASS "[-[:alnum:]\\Q,?;.:/!%$^*&~\"#'\\E]"
 #define HOSTCHARS_CLASS "[-[:alnum:]]"
-#define HOST HOSTCHARS_CLASS "+(\\." HOSTCHARS_CLASS "+)*"
+#define HOSTNAME HOSTCHARS_CLASS "+(?:\\." HOSTCHARS_CLASS "+)*"
+#define IPV6ADDRESS "\\[(?:[[:xdigit:]]{0,4}:){2,7}[[:xdigit:]]{0,4}\\]"
+#define HOST            "(?:" HOSTNAME "|" IPV6ADDRESS ")"
 #define PORT "(?:\\:[[:digit:]]{1,5})?"
 #define PATHCHARS_CLASS "[-[:alnum:]\\Q_$.+!*,:;@&=?/~#%\\E]"
 #define PATHTERM_CLASS "[^\\Q]'.:}>) \t\r\n,\"\\E]"
