const BLOB_URL_REGEX = /^\s*blob:/i;

export function isBlobUrl(value?: string | null): boolean {
  if (typeof value !== 'string') return false;
  return BLOB_URL_REGEX.test(value.trim());
}

export function sanitizeUrlArray(values?: string[]): string[] | undefined {
  if (!Array.isArray(values)) return values;
  return values.filter((value) => !isBlobUrl(value));
}

export function containsBlobMediaHtml(content: string): boolean {
  return /<(img|iframe)\b[^>]*\bsrc\s*=\s*["']\s*blob:/i.test(content);
}
