SPB Git forge

spb/fetcha

Public
11commits 1branches 0releases
1.5 MBsize
maindefault branch
16 days agolast push
TypeScript 97.5% SQL 1.4% Python 0.8%
1.0 KB · 38 lines typescript
Raw Blame History
1const SENSITIVE_HEADERS = new Set([2  "authorization",3  "cookie",4  "set-cookie",5  "proxy-authorization",6  "x-api-key",7  "x-auth-token",8  "x-fetcha-key",9]);1011export function redactHeaders(headers: Record<string, string> | undefined | null): Record<string, string> {12  const out: Record<string, string> = {};13  if (!headers) return out;14  for (const [k, v] of Object.entries(headers)) {15    out[k] = SENSITIVE_HEADERS.has(k.toLowerCase()) ? "[redacted]" : v;16  }17  return out;18}1920/** Strip anything that could identify an upstream provider from an error string. */21export function scrubProviderText(text: string): string {22  return text23    .replace(/oxylabs/gi, "upstream")24    .replace(/decodo/gi, "upstream")25    .replace(/smartproxy/gi, "upstream")26    .replace(/soax/gi, "upstream")27    .replace(/pr\.oxylabs\.io|gate\.decodo\.com|proxy\.soax\.com/gi, "upstream-gateway");28}2930export function extractDomain(url: string): string {31  try {32    const u = new URL(url);33    return u.hostname.toLowerCase().replace(/^www\./, "");34  } catch {35    return "";36  }37}38