INNER CODE UNIT · TypeScript

sanitizeText

Hash-Studios/Prism · infra/cloudflare/worker/src/index.ts:678

function sanitizeText(value: string): string {
  return value.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
}

function clipText(value: string, max: number): string {
  if (value.length <= max) {
    return value;
  }
  return `${value.slice(0, Math.max(0, max - 1))}…`;
}

function sanitizeImageUrl(value: string): string {
  if (!isNonEmptyString(value)) {
    return '';
  }
  try {
    const parsed = new URL(value);
    if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…