Allows for relative redirects
This commit is contained in:
parent
6b2ccc5ad4
commit
d7a65e6679
|
@ -999,6 +999,13 @@ func (c *client) handleGemini(u Url) {
|
|||
if strings.Replace(lowerRedirect, lowerOriginal, "", 1) == "/" {
|
||||
c.Visit(capsule.Content)
|
||||
} else {
|
||||
if !strings.Contains(capsule.Content, "://") {
|
||||
lnk, lnkErr := gemini.HandleRelativeUrl(capsule.Content, u.Full)
|
||||
if lnkErr == nil {
|
||||
capsule.Content = lnk
|
||||
}
|
||||
}
|
||||
|
||||
c.SetMessage(fmt.Sprintf("Follow redirect (y/n): %s?", capsule.Content), false)
|
||||
c.DrawMessage()
|
||||
ch := cui.Getch()
|
||||
|
|
|
@ -399,7 +399,7 @@ func parseGemini(b, currentUrl string) (string, []string) {
|
|||
}
|
||||
|
||||
if strings.Index(link, "://") < 0 {
|
||||
link, _ = handleRelativeUrl(link, currentUrl)
|
||||
link, _ = HandleRelativeUrl(link, currentUrl)
|
||||
}
|
||||
|
||||
links = append(links, link)
|
||||
|
@ -418,7 +418,7 @@ func parseGemini(b, currentUrl string) (string, []string) {
|
|||
}
|
||||
|
||||
// handleRelativeUrl provides link completion
|
||||
func handleRelativeUrl(relLink, current string) (string, error) {
|
||||
func HandleRelativeUrl(relLink, current string) (string, error) {
|
||||
base, err := url.Parse(current)
|
||||
if err != nil {
|
||||
return relLink, err
|
||||
|
|
Loading…
Reference in New Issue