/** A message with emails, tokens, URLs, paths, owner/repo names and quoted values removed; never a stack or the raw message. */ export function scrubErrorMessage(message: string): string { return message .replace(/[^\s@]+@[^\s@]+/g, "[email]") .replace(/https?:\/\/\S+/g, "[url]") .replace(/\b(?:gh[pousr]|gf[a-z]*|phc|sk|pk|rk|whsec|xox[a-z])_[A-Za-z0-9_-]+/g, "[token]") .replace(/\b[A-Za-z0-9_-]{32,}\b/g, "[token]") .replace(/(^|[\s"'(])\/[^\s"')]+/g, "$1[path]") .replace(/[\w.-]+\/[\w./-]+/g, "[path]") .replace(/(["'`])[^"'`]*\1/g, "[value]") .slice(0, 200); }