spb/search-box Public
Agentic web research engine — hypotheses, verbatim evidence, contradictions, sourced answers streamed live. Claude Opus 5 + Firecrawl + PostgreSQL.
TypeScript 76.9%
CSS 18.7%
SQL 2.1%
JavaScript 1.8%
Shell 0.5%
1/**2 * Search-box.ai3 * Author: Simon-Pierre Boucher4 * Contact: contact@spboucher.ai5 * File: packages/shared/src/text.ts6 * Description: Text sanitation for untrusted web content (JSON- and Postgres-safe).7 */89/**10 * Makes arbitrary scraped text safe for JSON serialization and Postgres storage:11 * removes lone UTF-16 surrogates (invalid JSON) and NUL bytes (rejected by PG).12 * Call again after slicing — a cut can split a surrogate pair.13 */14export function sanitizeText(s: string): string {15 return s16 .replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])/g, "")17 .replace(/(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "")18 .replace(/\u0000/g, "");19}20