1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-06-13 19:10:42 +00:00

Auto redirect if the new URL just adds a trailing slash (#271)

This commit is contained in:
mooff 2021-12-03 14:59:34 +00:00 committed by GitHub
parent 6e17b57837
commit 92fd9ed0bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -380,9 +380,10 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
return ret("", false)
}
redir := parsed.ResolveReference(parsedMeta).String()
justAddsSlash := (redir == u+"/")
// Prompt before redirecting to non-Gemini protocol
redirect := false
if !strings.HasPrefix(redir, "gemini") {
if !justAddsSlash && !strings.HasPrefix(redir, "gemini") {
if YesNo("Follow redirect to non-Gemini URL?\n" + redir) {
redirect = true
} else {
@ -390,7 +391,7 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
}
}
// Prompt before redirecting
autoRedirect := viper.GetBool("a-general.auto_redirect")
autoRedirect := justAddsSlash || viper.GetBool("a-general.auto_redirect")
if redirect || (autoRedirect && numRedirects < 5) || YesNo("Follow redirect?\n"+redir) {
if res.Status == gemini.StatusRedirectPermanent {
go cache.AddRedir(u, redir)