From aaa37cbb9f0601383512c12d7588790b5d7b4511 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 3 Nov 2019 16:42:16 -0800 Subject: [PATCH] Removes usage of library methods that are only available in 1.12 --- client.go | 6 +++--- url.go | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index 452dad1..3f99ecb 100644 --- a/client.go +++ b/client.go @@ -777,7 +777,7 @@ func (c *client) displayConfigValue(setting string) { func (c *client) SetMessage(msg string, isError bool) { c.MessageIsErr = isError - c.Message = strings.ReplaceAll(msg, "\t", "%09") + c.Message = strings.Replace(msg, "\t", "%09", -1) } func (c *client) DrawMessage() { @@ -845,7 +845,7 @@ func (c *client) goToLink(l string) { func (c *client) SetHeaderUrl() { if c.PageState.Length > 0 { u := c.PageState.History[c.PageState.Position].Location.Full - c.TopBar.url = strings.ReplaceAll(u, "\t", "%09") + c.TopBar.url = strings.Replace(u, "\t", "%09", -1) } else { c.TopBar.url = "" } @@ -857,7 +857,7 @@ func (c *client) Visit(url string) { c.SetMessage("Loading...", false) c.DrawMessage() - url = strings.ReplaceAll(url, "%09", "\t") + url = strings.Replace(url, "%09", "\t", -1) u, err := MakeUrl(url) if err != nil { c.SetMessage(err.Error(), true) diff --git a/url.go b/url.go index b77f0c6..b1b921e 100644 --- a/url.go +++ b/url.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "os" + "os/user" "path/filepath" "regexp" "strings" @@ -50,9 +50,12 @@ func MakeUrl(u string) (Url, error) { if local && len(u) > 8 { u = u[8:] } - home, err := os.UserHomeDir() + var home string + userinfo, err := user.Current() if err != nil { home = "" + } else { + home = userinfo.HomeDir } u = strings.Replace(u, "~", home, 1) res, err := filepath.Abs(u)