1export function sanitizeId(value) { 2 if (value == null) return ''; 3 return String(value) 4 .normalize('NFD') 5 .replace(/[Ì-ͯ]/g, '') 6 .toLowerCase() 7 .replace(/[^a-z0-9]+/g, '-') 8 .replace(/^-+|-+$/g, ''); 9} 10 11export function sanitizeScore(value) { 12 const n = Number(value); 13 if (!isFinite(n)) return 0; 14 return Math.min(100, Math.max(0, Math.round(n))); 15} 16 17export function sanitizeText(value, maxLength = 500) { 18 if (value == null) return ''; 19 return String(value).trim().slice(0, maxLength); 20} 21 22export function sanitizeUrl(value) { 23 if (value == null) return ''; 24 const s = String(value).trim(); 25 return s.startsWith('https://') || s.startsWith('http://') ? s : ''; 26} 27 28export function genId(prefix) { 29 return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; 30} 31 32export function sanitizeJson(value, fallback = []) { 33 try { 34 const parsed = JSON.parse(value); 35 return parsed ?? fallback; 36 } catch { 37 return fallback; 38 } 39}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.