Solved issue where not starting a resource with a slash caused odd behavior

This commit is contained in:
sloumdrone 2019-05-22 17:57:12 -07:00
parent e746fe9b20
commit 9a25ad6c51
2 changed files with 6 additions and 6 deletions

View File

@ -30,7 +30,7 @@ type Url struct {
// an error (or nil).
func MakeUrl(u string) (Url, error) {
var out Url
re := regexp.MustCompile(`^((?P<scheme>gopher|http|https|ftp|telnet):\/\/)?(?P<host>[\w\-\.\d]+)(?::(?P<port>\d+)?)?(?:/(?P<type>[01345679gIhisp])?)?(?P<resource>(?:[\/|Uu].*)?)?$`)
re := regexp.MustCompile(`^((?P<scheme>gopher|http|https|ftp|telnet):\/\/)?(?P<host>[\w\-\.\d]+)(?::(?P<port>\d+)?)?(?:/(?P<type>[01345679gIhisp])?)?(?P<resource>(?:[\/|Uu]?.*)?)?$`)
match := re.FindStringSubmatch(u)
if valid := re.MatchString(u); !valid {
@ -72,6 +72,10 @@ func MakeUrl(u string) (Url, error) {
out.Gophertype = "1"
}
if out.Scheme == "gopher" && out.Gophertype == "" {
out.Gophertype = "0"
}
switch out.Gophertype {
case "1", "0", "h", "7":
out.IsBinary = false
@ -79,9 +83,6 @@ func MakeUrl(u string) (Url, error) {
out.IsBinary = true
}
if out.Scheme == "gopher" && out.Gophertype == "" {
out.Gophertype = "0"
}
out.Full = out.Scheme + "://" + out.Host + ":" + out.Port + "/" + out.Gophertype + out.Resource

View File

@ -22,7 +22,7 @@ var userinfo, _ = user.Current()
var settings config.Config
var options = map[string]string{
"homeurl": "gopher://colorfield.space:70/1/bombadillo-info",
"savelocation": userinfo.HomeDir + "/Downloads/",
"savelocation": userinfo.HomeDir,
"searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs",
"openhttp": "false",
"httpbrowser": "lynx",
@ -171,7 +171,6 @@ func goToURL(u string) error {
return err
}
} else if v.Address.IsBinary {
// TO DO: run this into the write to file method
return saveFileFromData(v)
} else {
history.Add(v)