From 30bbfa7161b73bcda701ddaddad0d57f0da6376b Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 26 May 2019 10:06:43 -0700 Subject: [PATCH] Solves issue where 0 crashes program --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4eb9996..314afae 100644 --- a/main.go +++ b/main.go @@ -157,6 +157,9 @@ func simpleCommand(a string) error { } func goToURL(u string) error { + if num, _ := regexp.MatchString(`^-?\d+.?\d*$`, u); num { + return goToLink(u) + } quickMessage("Loading...", false) v, err := gopher.Visit(u, options["openhttp"]) if err != nil { @@ -182,10 +185,10 @@ func goToURL(u string) error { } func goToLink(l string) error { - if num, _ := regexp.MatchString(`^\d+$`, l); num && history.Length > 0 { + if num, _ := regexp.MatchString(`^-?\d+$`, l); num && history.Length > 0 { linkcount := len(history.Collection[history.Position].Links) item, _ := strconv.Atoi(l) - if item <= linkcount { + if item <= linkcount && item > 0 { linkurl := history.Collection[history.Position].Links[item-1] quickMessage("Loading...", false) v, err := gopher.Visit(linkurl, options["openhttp"])