bigbuffet-rw/app/soapbox/utils/status.js

15 lines
437 B
JavaScript

export const getFirstExternalLink = status => {
try {
// Pulled from Pleroma's media parser
const selector = 'a:not(.mention,.hashtag,.attachment,[rel~="tag"])';
const element = document.createElement('div');
element.innerHTML = status.content;
return element.querySelector(selector);
} catch {
return null;
}
};
export const shouldHaveCard = status => {
return Boolean(getFirstExternalLink(status));
};