forked from sloum/bombadillo
Merge pull request 'Updates `handleGemini` to allow for handling relative redirects' (#182) from fixes-relative-redirects into release2.3.2
Reviewed-on: sloum/bombadillo#182
This commit is contained in:
commit
a346d78c7b
|
@ -1001,6 +1001,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()
|
||||
|
|
|
@ -404,7 +404,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)
|
||||
|
@ -423,7 +423,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