diff --git a/src/utils/getUrlAndLabels.ts b/src/utils/getUrlAndLabels.ts index fcfb3b4..356d293 100644 --- a/src/utils/getUrlAndLabels.ts +++ b/src/utils/getUrlAndLabels.ts @@ -28,10 +28,12 @@ export function getUrlAndLabels(ctx: Filter) } labels = [] } else { - // retrieve the first url from the message - const urlMatch = message.match(/(?:https?:\/\/|www\.)\S+?(?=\s|$)/); - url = urlMatch ? urlMatch[0] : ''; - labels = []; + // retrieve the first url from the message/post + const urlEntity = ctx.entities('url').find((entity) => entity.type === 'url') + if (urlEntity && urlEntity.text) { + url = urlEntity.text + } + labels = [] } // add default label