14 lines
553 B
TypeScript

export function slugify(input: string): string {
const normalized = input
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "");
return normalized.length > 0 ? normalized.slice(0, 40) : "update";
}
export function extractPrInfo(text: string): { prUrl: string | null; prNumber: number | null } {
const url = text.match(/https?:\/\/\S+/)?.[0] ?? null;
const num = text.match(/(?:pulls|pull|pr)\/(\d+)/i)?.[1] ?? text.match(/#(\d+)/)?.[1] ?? null;
return { prUrl: url, prNumber: num === null ? null : Number(num) };
}