Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
/**
* Mirror of `App\Support\FacebookLinkPreview`. Facebook rejects many
* facebook.com, fb.com and fb.me links, so the preview skips the same hosts
* the publisher does.
*/
const FACEBOOK_HOSTS = ['facebook.com', 'fb.com', 'fb.me'] as const;
const trimTrailingPunctuation = (url: string): string => {
const trimmed = url.replace(/[.,;:!?]$/, '');
return trimmed.endsWith(')') && !trimmed.includes('(')
? trimmed.slice(0, -1)
: trimmed;
};
const isFacebookOwnedUrl = (url: string): boolean => {
try {
const host = new URL(url).hostname.toLowerCase();
return FACEBOOK_HOSTS.some(
(domain) => host === domain || host.endsWith(`.${domain}`),
);
} catch {
return false;
}
};
export const facebookLinkPreviewUrl = (text: string): string | null =>
[...text.matchAll(/https?:\/\/\S+/gu)]
.map(([raw]) => trimTrailingPunctuation(raw))
.find((url) => !isFacebookOwnedUrl(url)) ?? null;