mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-27 22:23:43 +01:00
Remove href attribute of invalid links instead of crashing
This commit is contained in:
parent
0aee74d78a
commit
cbd75fe128
1 changed files with 12 additions and 7 deletions
|
@ -106,14 +106,19 @@ export default class StatusContent extends React.PureComponent {
|
|||
link.setAttribute('title', link.href);
|
||||
link.classList.add('unhandled-link');
|
||||
|
||||
if (tagLinks && isLinkMisleading(link)) {
|
||||
// Add a tag besides the link to display its origin
|
||||
try {
|
||||
if (tagLinks && isLinkMisleading(link)) {
|
||||
// Add a tag besides the link to display its origin
|
||||
|
||||
const tag = document.createElement('span');
|
||||
tag.classList.add('link-origin-tag');
|
||||
tag.textContent = `[${new URL(link.href).host}]`;
|
||||
link.insertAdjacentText('beforeend', ' ');
|
||||
link.insertAdjacentElement('beforeend', tag);
|
||||
const tag = document.createElement('span');
|
||||
tag.classList.add('link-origin-tag');
|
||||
tag.textContent = `[${new URL(link.href).host}]`;
|
||||
link.insertAdjacentText('beforeend', ' ');
|
||||
link.insertAdjacentElement('beforeend', tag);
|
||||
}
|
||||
} catch (TypeError) {
|
||||
// Just to be safe
|
||||
if (tagLinks) link.removeAttribute('href');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue