forked from sloum/bombadillo
Solved issue where not starting a resource with a slash caused odd behavior
This commit is contained in:
parent
e746fe9b20
commit
9a25ad6c51
|
@ -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
|
||||
|
||||
|
|
3
main.go
3
main.go
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue