const SPOTIFY_EXTRACTOR = /^\/(?(?:album|artist|episode|playlist|tracks?))\/?(?[a-zA-Z0-9]{22})/gi; function embed_spotify(link_info) { const is_spotify_link = ["spotify.com"].includes(link_info.domain?.toLowerCase()); if (!is_spotify_link) { return; } SPOTIFY_EXTRACTOR.lastIndex = 0; const { groups: { item_type, item_id }, } = SPOTIFY_EXTRACTOR.exec(link_info.path ?? "") ?? { groups: {} }; if (!item_id) { return; } return `
`; }