refactor: use optional chaining and nullish coalescing

This commit is contained in:
Johann150 2022-08-25 00:03:55 +02:00
parent 6fed87f85d
commit f119914b98
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -109,7 +109,7 @@ export function toHtml(nodes: mfm.MfmNode[] | null, mentionedRemoteUsers: IMenti
const a = doc.createElement('a');
const { username, host, acct } = node.props;
const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host);
a.href = remoteUserInfo ? (remoteUserInfo.url ? remoteUserInfo.url : remoteUserInfo.uri) : `${config.url}/${acct}`;
a.href = remoteUserInfo?.url ?? remoteUserInfo?.uri ?? `${config.url}/${acct}`;
a.className = 'u-url mention';
a.textContent = acct;
return a;