Merge pull request 'Fixes querystring chaining issue' (#159) from querystring into release-2.3.0
This commit is contained in:
commit
47863519a2
28
client.go
28
client.go
|
@ -664,7 +664,7 @@ func (c *client) doLinkCommand(action, target string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) search(query, url, question string) {
|
func (c *client) search(query, uri, question string) {
|
||||||
var entry string
|
var entry string
|
||||||
var err error
|
var err error
|
||||||
if query == "" {
|
if query == "" {
|
||||||
|
@ -688,22 +688,32 @@ func (c *client) search(query, url, question string) {
|
||||||
} else {
|
} else {
|
||||||
entry = query
|
entry = query
|
||||||
}
|
}
|
||||||
if url == "" {
|
if uri == "" {
|
||||||
url = c.Options["searchengine"]
|
uri = c.Options["searchengine"]
|
||||||
}
|
}
|
||||||
u, err := MakeUrl(url)
|
u, err := MakeUrl(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.SetMessage("The search url is not a valid url", true)
|
c.SetMessage("The search url is not valid", true)
|
||||||
c.DrawMessage()
|
c.DrawMessage()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var rootUrl string
|
||||||
switch u.Scheme {
|
switch u.Scheme {
|
||||||
case "gopher":
|
case "gopher":
|
||||||
c.Visit(fmt.Sprintf("%s\t%s", u.Full, entry))
|
if ind := strings.Index(entry, "\t"); ind >= 0 {
|
||||||
|
rootUrl = u.Full[:ind]
|
||||||
|
} else {
|
||||||
|
rootUrl = u.Full
|
||||||
|
}
|
||||||
|
c.Visit(fmt.Sprintf("%s\t%s", rootUrl, entry))
|
||||||
case "gemini":
|
case "gemini":
|
||||||
// TODO url escape the entry variable
|
if ind := strings.Index(entry, "?"); ind >= 0 {
|
||||||
escapedEntry := entry
|
rootUrl = u.Full[:ind]
|
||||||
c.Visit(fmt.Sprintf("%s?%s", u.Full, escapedEntry))
|
} else {
|
||||||
|
rootUrl = u.Full
|
||||||
|
}
|
||||||
|
// escapedEntry := url.QueryEscape(entry) // TODO confirm expected behavior re: escaping
|
||||||
|
c.Visit(fmt.Sprintf("%s?%s", rootUrl, entry))
|
||||||
case "http", "https":
|
case "http", "https":
|
||||||
c.Visit(u.Full)
|
c.Visit(u.Full)
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue