1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-07-05 11:02:49 +00:00

Fix incorrect display text in links

This commit is contained in:
bouncepaw 2020-12-17 19:58:11 +05:00
parent e8f9bf608f
commit 598a87f878

View File

@ -22,9 +22,11 @@ func LinkParts(addr, display, hyphaName string) (href, text, class, icon string)
case strings.ContainsRune(addr, ':'): case strings.ContainsRune(addr, ':'):
pos := strings.IndexRune(addr, ':') pos := strings.IndexRune(addr, ':')
destination := addr[:pos] destination := addr[:pos]
text = addr[pos+1:] if display == "" {
if strings.HasPrefix(text, "//") && len(text) > 2 { text = addr[pos+1:]
text = text[2:] if strings.HasPrefix(text, "//") && len(text) > 2 {
text = text[2:]
}
} }
return addr, text, "wikilink_external", fmt.Sprintf(`<img class="wikilink__destination-type" src="/static/icon/%s" width="16" height="16"/>`, destination) return addr, text, "wikilink_external", fmt.Sprintf(`<img class="wikilink__destination-type" src="/static/icon/%s" width="16" height="16"/>`, destination)
case strings.HasPrefix(addr, "/"): case strings.HasPrefix(addr, "/"):