mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-21 16:18:55 +00:00
Pure, synchronous URL→descriptor matchers for YouTube, Vimeo, Instagram, Pinterest, TikTok, X, Spotify, Google Maps and OpenStreetMap, plus the shared embed primitives (error boundary, fail card, escape-html, dark-mode hook, sizing token). Declares the mermaid + dompurify deps used by the fenced renderers.
27 lines
611 B
TypeScript
27 lines
611 B
TypeScript
import { bareHost, type EmbedMatcher } from './types'
|
|
|
|
export const twitter: EmbedMatcher = url => {
|
|
const host = bareHost(url.hostname)
|
|
|
|
if (host !== 'twitter.com' && host !== 'x.com') {
|
|
return null
|
|
}
|
|
|
|
const segments = url.pathname.split('/').filter(Boolean)
|
|
const statusIndex = segments.indexOf('status')
|
|
const id = statusIndex >= 0 ? segments[statusIndex + 1] : ''
|
|
|
|
if (!/^\d+$/.test(id || '')) {
|
|
return null
|
|
}
|
|
|
|
return {
|
|
id: `twitter:${id}`,
|
|
label: 'X',
|
|
maxWidth: 480,
|
|
provider: 'twitter',
|
|
renderer: 'tweet',
|
|
sourceUrl: url.toString(),
|
|
tweetId: id
|
|
}
|
|
}
|