[mastodon-client] Improve mfm-to-html handling of links

This commit is contained in:
Laura Hausmann 2023-10-12 15:32:16 +02:00
parent afee7b6174
commit 19f8c0aafc
Signed by: zotan
GPG key ID: D044E84C5BE01605

View file

@ -123,6 +123,8 @@ export class MfmHelpers {
link(node) {
const a = doc.createElement("a");
a.setAttribute("rel", "nofollow noopener noreferrer");
a.setAttribute("target", "_blank");
a.href = node.props.url;
appendChildren(node.children, a);
return a;
@ -178,8 +180,10 @@ export class MfmHelpers {
url(node) {
const a = doc.createElement("a");
a.setAttribute("rel", "nofollow noopener noreferrer");
a.setAttribute("target", "_blank");
a.href = node.props.url;
a.textContent = node.props.url;
a.textContent = node.props.url.replace(/^https?:\/\//, '');
return a;
},