From b85b65dda083406c4a55b29242a2dc5d6a0f81b1 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Sat, 1 Jul 2023 13:37:06 +0300 Subject: [PATCH] use find instead of filter --- main.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.mjs b/main.mjs index 912af4e..0aed906 100644 --- a/main.mjs +++ b/main.mjs @@ -57,8 +57,8 @@ function getMessageUrl(msg) { } function getTextLink(msg) { - const textLinks = (msg.entities ?? []).filter(isTextLink); - return textLinks.length ? textLinks[0].url : null; + const textLink = (msg.entities ?? []).find(isTextLink); + return textLink ? textLink.url : null; } function isTextLink(msgEntity) {