Skip to content

Commit

Permalink
πŸƒ Remove unnecessary find methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Rnbsov committed Mar 15, 2024
1 parent f997755 commit e75b7e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/getUrlAndLabels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export function getUrlAndLabels(ctx: Filter<MyContext, 'message:entities:url'>)
;({ url, labels } = parseUrls(message)[0])
} else if (ctx.entities('text_link').length > 0) {
// handle case when user sends a message with text formatted link
const linkEntity = ctx.entities('text_link').find((entity) => entity.type === 'text_link')
const linkEntity = ctx.entities('text_link')[0]
if (linkEntity && linkEntity.url) {
url = linkEntity.url
}
labels = []
} else {
// retrieve the first url from the message/post
const urlEntity = ctx.entities('url').find((entity) => entity.type === 'url')
const urlEntity = ctx.entities('url')[0]
if (urlEntity && urlEntity.text) {
url = urlEntity.text
}
Expand Down

0 comments on commit e75b7e6

Please sign in to comment.