social-link-parser
Version:
Extract usernames, IDs, and metadata from social media URLs across 100+ platforms
44 lines • 1.69 kB
JavaScript
import { Platforms } from '../../core/types.js';
import { normalize } from '../../utils/url.js';
import { QUERY_HASH } from '../../utils/constants.js';
const domains = ['teams.microsoft.com', 'teams.live.com'];
const subdomains = [];
export const microsoftteams = {
id: Platforms.MicrosoftTeams,
name: 'MicrosoftTeams',
color: '#464EB8',
domains: domains,
subdomains: subdomains,
patterns: {
profile: /^$/,
handle: /^$/,
content: {
team: new RegExp(`^https?://teams\\.microsoft\\.com/l/team/(\\w+)/conversations\\?.*groupId=([0-9a-f-]{36})${QUERY_HASH}`, 'i'),
meeting: new RegExp(`^https?://teams\\.live\\.com/meet/([A-Za-z0-9-]+)/?${QUERY_HASH}$`, 'i')
}
},
detect(url) {
if (!this.domains.some(domain => url.includes(domain)))
return false;
return !!(this.patterns.content?.team?.test(url)) || !!(this.patterns.content?.meeting?.test(url));
},
extract(url, result) {
const t = this.patterns.content?.team?.exec(url);
if (t) {
result.ids.teamId = t[1];
result.ids.groupId = t[2];
result.metadata.contentType = 'team';
return;
}
const m = this.patterns.content?.meeting?.exec(url);
if (m) {
result.ids.meetingId = m[1];
result.metadata.contentType = 'meeting';
}
},
validateHandle() { return false; },
buildProfileUrl() { return 'https://teams.microsoft.com'; },
buildContentUrl(_, id) { return `https://teams.microsoft.com/l/team/${id}`; },
normalizeUrl(url) { return normalize(url); },
};
//# sourceMappingURL=index.js.map