UNPKG

social-link-parser

Version:

Extract usernames, IDs, and metadata from social media URLs across 100+ platforms

52 lines 1.71 kB
import { Platforms } from '../../core/types.js'; import { normalize } from '../../utils/url.js'; import { createDomainPattern } from '../../utils/url.js'; import { QUERY_HASH } from '../../utils/constants.js'; const domains = ['hoo.be']; const subdomains = []; const DOMAIN_PATTERN = createDomainPattern(domains, subdomains); const MIN = 3, MAX = 70; export const hoobe = { id: Platforms.HooBe, name: 'Hoo.be', color: '#000000', domains: domains, subdomains: subdomains, patterns: { profile: new RegExp(`^https?://${DOMAIN_PATTERN}/([A-Za-z0-9][A-Za-z0-9.-]{1,68}[A-Za-z0-9-])/?${QUERY_HASH}$`, 'i'), handle: /^[A-Za-z0-9][A-Za-z0-9.-]{1,68}[A-Za-z0-9-]$/, }, detect(url) { if (!this.domains.some(domain => url.includes(domain))) return false; return this.patterns.profile.test(url); }, extract(url, result) { const m = this.patterns.profile.exec(url); if (m) { result.username = m[1]; result.metadata.isProfile = true; result.metadata.contentType = 'profile'; } }, validateHandle(handle) { if (!handle || typeof handle !== 'string') return false; if (handle.length < MIN || handle.length > MAX) return false; if (!/^[A-Za-z0-9]/.test(handle)) return false; if (handle.endsWith('.')) return false; if (!/^[A-Za-z0-9.-]+$/.test(handle)) return false; return true; }, buildProfileUrl(username) { return `https://hoo.be/${username}`; }, normalizeUrl(url) { return normalize(url); }, }; //# sourceMappingURL=index.js.map