social-link-parser
Version:
Extract usernames, IDs, and metadata from social media URLs across 100+ platforms
55 lines • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.hoobe = void 0;
const types_1 = require("../../core/types");
const url_1 = require("../../utils/url");
const url_2 = require("../../utils/url");
const constants_1 = require("../../utils/constants");
const domains = ['hoo.be'];
const subdomains = [];
const DOMAIN_PATTERN = (0, url_2.createDomainPattern)(domains, subdomains);
const MIN = 3, MAX = 70;
exports.hoobe = {
id: types_1.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-])/?${constants_1.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 (0, url_1.normalize)(url);
},
};
//# sourceMappingURL=index.js.map