import {SembleUrlType} from "./citoid"; export interface UrlPattern { regex: RegExp; type: SembleUrlType; description?: string; } export class UrlClassifier { private static readonly patterns: UrlPattern[] = [ { regex: /^https:\/\/bsky\.app\/profile\/[^/]+\/post\/[^/]+$/, type: SembleUrlType.SOCIAL, description: "Bluesky post" }, { regex: /^https:\/\/blacksky\.community\/profile\/[^/]+\/post\/[^/]+$/, type: SembleUrlType.SOCIAL, description: "Blacksky community post" }, { regex: /^https:\/\/deer\.social\/profile\/[^/]+\/post\/[^/]+$/, type: SembleUrlType.SOCIAL, description: "Deer social post" }, { regex: /^https:\/\/smokesignal\.events\/[^/]+\/[^/]+$/, type: SembleUrlType.LINK, description: "Smokesignal event" }, { regex: /^https:\/\/tangled\.org\/[^/]+\/[^/]+/, type: SembleUrlType.SOFTWARE, description: "Tangled repo" }, { regex: /^https:\/\/[^./]+\.leaflet\.pub\/[^/]+$/, type: SembleUrlType.ARTICLE, description: "Leaflet article" } ]; public static classifyUrl(url: string): SembleUrlType | null { for (const pattern of this.patterns) { if (pattern.regex.test(url)) { return pattern.type; } } return null; } }