Fix handling of queries / indexsearch (itemtype 7)
This commit is contained in:
parent
09b7e10086
commit
9f2e515a5e
|
@ -45,7 +45,7 @@ func renderDirectory(w http.ResponseWriter, tpl *template.Template, hostport str
|
|||
} else {
|
||||
hostport = fmt.Sprintf("%s:%d", x.Host, x.Port)
|
||||
}
|
||||
path := url.QueryEscape(x.Selector)
|
||||
path := url.PathEscape(x.Selector)
|
||||
path = strings.Replace(path, "%2F", "/", -1)
|
||||
tr.Link = template.URL(
|
||||
fmt.Sprintf(
|
||||
|
@ -73,25 +73,35 @@ func MakeGopherProxyHandler(tpl *template.Template, uri string) Handler {
|
|||
return func(w http.ResponseWriter, req *http.Request) {
|
||||
parts := strings.Split(strings.TrimPrefix(req.URL.Path, "/"), "/")
|
||||
hostport := parts[0]
|
||||
path := strings.Join(parts[1:], "/")
|
||||
|
||||
if len(hostport) == 0 {
|
||||
http.Redirect(w, req, "/"+uri, http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
var qs string
|
||||
|
||||
path := strings.Join(parts[1:], "/")
|
||||
|
||||
if req.URL.RawQuery != "" {
|
||||
qs = fmt.Sprintf("?%s", url.QueryEscape(req.URL.RawQuery))
|
||||
}
|
||||
|
||||
uri, err := url.QueryUnescape(path)
|
||||
if err != nil {
|
||||
io.WriteString(w, fmt.Sprintf("<b>Error:</b><pre>%s</pre>", err))
|
||||
return
|
||||
}
|
||||
|
||||
res, err := gopher.Get(
|
||||
fmt.Sprintf(
|
||||
"gopher://%s/%s",
|
||||
"gopher://%s/%s%s",
|
||||
hostport,
|
||||
uri,
|
||||
qs,
|
||||
),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
io.WriteString(w, fmt.Sprintf("<b>Error:</b><pre>%s</pre>", err))
|
||||
return
|
||||
|
|
|
@ -22,7 +22,7 @@ $(document).ready(function () {
|
|||
e.preventDefault();
|
||||
var query = prompt("Please enter required input: ", "");
|
||||
if (query != null) {
|
||||
window.location = e.target.href + "%09" + query;
|
||||
window.location = e.target.href + "?" + query;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue