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