diff --git a/src/js/components/user/Avatar.tsx b/src/js/components/user/Avatar.tsx index cdc71ac3..43eb3ad7 100644 --- a/src/js/components/user/Avatar.tsx +++ b/src/js/components/user/Avatar.tsx @@ -10,7 +10,7 @@ import Show from '../helpers/Show'; import ProxyImg from '../ProxyImg.tsx'; type Props = { - str: unknown; + str: string; hidePicture?: boolean; showTooltip?: boolean; activity?: string; @@ -23,7 +23,10 @@ const MyAvatar: React.FC = (props) => { const [avatar, setAvatar] = useState(null); const [hasError, setHasError] = useState(false); - const hex = React.useMemo(() => Key.toNostrHexAddress(props.str as string), [props.str]); + const hex = React.useMemo( + () => Key.toNostrHexAddress(props.str as string) || props.str, + [props.str], + ); const { picture, name } = useProfile(hex || ''); diff --git a/src/js/nostr/Key.ts b/src/js/nostr/Key.ts index d29922d6..5e940e05 100644 --- a/src/js/nostr/Key.ts +++ b/src/js/nostr/Key.ts @@ -242,7 +242,12 @@ export default { try { const hex = new Hex(address); - return hex.toBech32(prefix); + const bech32 = hex.toBech32(prefix); + if (bech32.length < 60) { + // not a nostr key + return null; + } + return bech32; } catch (e) { // not a valid hex console.error(address, e);