mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Merge branch 'bare-linkification' into 'main'
Fix linkification of bare domains See merge request soapbox-pub/ditto!360
This commit is contained in:
commit
cbe83af7e7
1 changed files with 6 additions and 2 deletions
|
|
@ -16,7 +16,7 @@ const linkifyOpts: linkify.Opts = {
|
||||||
const href = Conf.local(`/tags/${tag}`);
|
const href = Conf.local(`/tags/${tag}`);
|
||||||
return `<a class=\"mention hashtag\" href=\"${href}\" rel=\"tag\"><span>#</span>${tag}</a>`;
|
return `<a class=\"mention hashtag\" href=\"${href}\" rel=\"tag\"><span>#</span>${tag}</a>`;
|
||||||
},
|
},
|
||||||
url: ({ content }) => {
|
url: ({ attributes, content }) => {
|
||||||
try {
|
try {
|
||||||
const { decoded } = nip21.parse(content);
|
const { decoded } = nip21.parse(content);
|
||||||
const pubkey = getDecodedPubkey(decoded);
|
const pubkey = getDecodedPubkey(decoded);
|
||||||
|
|
@ -28,7 +28,11 @@ const linkifyOpts: linkify.Opts = {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
return `<a href="${content}">${content}</a>`;
|
const attr = Object.entries(attributes)
|
||||||
|
.map(([name, value]) => `${name}="${value}"`)
|
||||||
|
.join(' ');
|
||||||
|
|
||||||
|
return `<a ${attr}>${content}</a>`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue