mirror of
https://github.com/makew0rld/amfora.git
synced 2025-02-02 15:07:34 -05:00
🔥 Use gemini.QueryEscape instead
This commit is contained in:
parent
dbe87a3e99
commit
11c3b1fec9
@ -11,6 +11,7 @@ import (
|
||||
"github.com/makeworld-the-better-one/amfora/config"
|
||||
"github.com/makeworld-the-better-one/amfora/renderer"
|
||||
"github.com/makeworld-the-better-one/amfora/structs"
|
||||
"github.com/makeworld-the-better-one/go-gemini"
|
||||
"github.com/spf13/viper"
|
||||
"gitlab.com/tslocum/cview"
|
||||
)
|
||||
@ -172,7 +173,7 @@ func Init() {
|
||||
// Detect if it's a search or URL
|
||||
if strings.Contains(query, " ") ||
|
||||
(!strings.Contains(query, "//") && !strings.Contains(query, ".") && !strings.HasPrefix(query, "about:")) {
|
||||
u := viper.GetString("a-general.search") + "?" + queryEscape(query)
|
||||
u := viper.GetString("a-general.search") + "?" + gemini.QueryEscape(query)
|
||||
cache.RemovePage(u) // Don't use the cached version of the search
|
||||
URL(u)
|
||||
} else {
|
||||
|
@ -419,7 +419,7 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
|
||||
if ok {
|
||||
// Make another request with the query string added
|
||||
// + chars are replaced because PathEscape doesn't do that
|
||||
parsed.RawQuery = queryEscape(userInput)
|
||||
parsed.RawQuery = gemini.QueryEscape(userInput)
|
||||
if len(parsed.String()) > gemini.URLMaxLength {
|
||||
Error("Input Error", "URL for that input would be too long.")
|
||||
return ret("", false)
|
||||
|
@ -3,7 +3,6 @@ package display
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@ -45,12 +44,6 @@ func textWidth() int {
|
||||
return viper.GetInt("a-general.max_width")
|
||||
}
|
||||
|
||||
// queryEscape is the same as url.PathEscape, but it also replaces the +.
|
||||
// This is because Gemini requires percent-escaping for queries.
|
||||
func queryEscape(path string) string {
|
||||
return strings.ReplaceAll(url.PathEscape(path), "+", "%2B")
|
||||
}
|
||||
|
||||
// resolveRelLink returns an absolute link for the given absolute link and relative one.
|
||||
// It also returns an error if it could not resolve the links, which should be displayed
|
||||
// to the user.
|
||||
|
Loading…
x
Reference in New Issue
Block a user