Removes usage of library methods that are only available in 1.12

This commit is contained in:
sloumdrone 2019-11-03 16:42:16 -08:00
parent 20d2c706b4
commit aaa37cbb9f
2 changed files with 8 additions and 5 deletions

View File

@ -777,7 +777,7 @@ func (c *client) displayConfigValue(setting string) {
func (c *client) SetMessage(msg string, isError bool) { func (c *client) SetMessage(msg string, isError bool) {
c.MessageIsErr = isError c.MessageIsErr = isError
c.Message = strings.ReplaceAll(msg, "\t", "%09") c.Message = strings.Replace(msg, "\t", "%09", -1)
} }
func (c *client) DrawMessage() { func (c *client) DrawMessage() {
@ -845,7 +845,7 @@ func (c *client) goToLink(l string) {
func (c *client) SetHeaderUrl() { func (c *client) SetHeaderUrl() {
if c.PageState.Length > 0 { if c.PageState.Length > 0 {
u := c.PageState.History[c.PageState.Position].Location.Full 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 { } else {
c.TopBar.url = "" c.TopBar.url = ""
} }
@ -857,7 +857,7 @@ func (c *client) Visit(url string) {
c.SetMessage("Loading...", false) c.SetMessage("Loading...", false)
c.DrawMessage() c.DrawMessage()
url = strings.ReplaceAll(url, "%09", "\t") url = strings.Replace(url, "%09", "\t", -1)
u, err := MakeUrl(url) u, err := MakeUrl(url)
if err != nil { if err != nil {
c.SetMessage(err.Error(), true) c.SetMessage(err.Error(), true)

7
url.go
View File

@ -2,7 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"os" "os/user"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strings" "strings"
@ -50,9 +50,12 @@ func MakeUrl(u string) (Url, error) {
if local && len(u) > 8 { if local && len(u) > 8 {
u = u[8:] u = u[8:]
} }
home, err := os.UserHomeDir() var home string
userinfo, err := user.Current()
if err != nil { if err != nil {
home = "" home = ""
} else {
home = userinfo.HomeDir
} }
u = strings.Replace(u, "~", home, 1) u = strings.Replace(u, "~", home, 1)
res, err := filepath.Abs(u) res, err := filepath.Abs(u)