mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
hicli/html: convert plaintext matrix.to links to matrix: URIs
This commit is contained in:
parent
3fdaf8ae4e
commit
c6cdb820ea
1 changed files with 11 additions and 4 deletions
|
@ -179,11 +179,18 @@ func writeURL(w *strings.Builder, addr []byte) {
|
|||
writeEscapedBytes(w, addr)
|
||||
return
|
||||
}
|
||||
if parsedURL.Scheme == "" {
|
||||
parsedURL.Scheme = "https"
|
||||
w.WriteString(`<a`)
|
||||
if matrixURI, err := id.ProcessMatrixToURL(parsedURL); err == nil {
|
||||
writeAttribute(w, "href", matrixURI.String())
|
||||
writeAttribute(w, "class", matrixURIClassName(matrixURI)+" hicli-matrix-uri-plaintext")
|
||||
} else {
|
||||
if parsedURL.Scheme == "" {
|
||||
parsedURL.Scheme = "https"
|
||||
}
|
||||
writeAttribute(w, "target", "_blank")
|
||||
writeAttribute(w, "rel", "noreferrer noopener")
|
||||
writeAttribute(w, "href", parsedURL.String())
|
||||
}
|
||||
w.WriteString(`<a target="_blank" rel="noreferrer noopener"`)
|
||||
writeAttribute(w, "href", parsedURL.String())
|
||||
w.WriteByte('>')
|
||||
writeEscapedBytes(w, addr)
|
||||
w.WriteString("</a>")
|
||||
|
|
Loading…
Add table
Reference in a new issue