mirror of
https://github.com/makew0rld/amfora.git
synced 2024-10-26 07:39:49 +03:00
Auto redirect if the new URL just adds a trailing slash (#271)
This commit is contained in:
parent
6e17b57837
commit
92fd9ed0bc
@ -380,9 +380,10 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
|
|||||||
return ret("", false)
|
return ret("", false)
|
||||||
}
|
}
|
||||||
redir := parsed.ResolveReference(parsedMeta).String()
|
redir := parsed.ResolveReference(parsedMeta).String()
|
||||||
|
justAddsSlash := (redir == u+"/")
|
||||||
// Prompt before redirecting to non-Gemini protocol
|
// Prompt before redirecting to non-Gemini protocol
|
||||||
redirect := false
|
redirect := false
|
||||||
if !strings.HasPrefix(redir, "gemini") {
|
if !justAddsSlash && !strings.HasPrefix(redir, "gemini") {
|
||||||
if YesNo("Follow redirect to non-Gemini URL?\n" + redir) {
|
if YesNo("Follow redirect to non-Gemini URL?\n" + redir) {
|
||||||
redirect = true
|
redirect = true
|
||||||
} else {
|
} else {
|
||||||
@ -390,7 +391,7 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Prompt before redirecting
|
// 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 redirect || (autoRedirect && numRedirects < 5) || YesNo("Follow redirect?\n"+redir) {
|
||||||
if res.Status == gemini.StatusRedirectPermanent {
|
if res.Status == gemini.StatusRedirectPermanent {
|
||||||
go cache.AddRedir(u, redir)
|
go cache.AddRedir(u, redir)
|
||||||
|
Loading…
Reference in New Issue
Block a user