Files
eranos/src/lib/blurhash.ts
T
Chad Curtis 36373400f8 Fix crash on invalid blurhash strings from Nostr events
Validate blurhash hashes before passing them to react-blurhash's
<Blurhash> component, which throws when the encoded length doesn't
match the component count header. Malformed hashes from third-party
events (e.g. length 92 instead of 94) now gracefully fall back to a
skeleton placeholder instead of crashing the page.
2026-04-18 04:39:14 -05:00

8 lines
271 B
TypeScript

import { isBlurhashValid } from 'blurhash';
/** Returns `true` when `hash` is a structurally valid blurhash string. */
export function isValidBlurhash(hash: string | undefined | null): hash is string {
if (!hash) return false;
return isBlurhashValid(hash).result;
}