fix: trim invalid chars from NostrLink

This commit is contained in:
2023-11-08 10:06:16 +00:00
parent b4697d1e04
commit a2bcb936ef
5 changed files with 34 additions and 21 deletions

View File

@ -5,7 +5,7 @@ import { useNavigate } from "react-router-dom";
import { useIntl, FormattedMessage } from "react-intl";
import { HexKey, Nip46Signer, NotEncrypted, PinEncrypted, PrivateKeySigner } from "@snort/system";
import { bech32ToHex, getPublicKey, isHex, unwrap } from "SnortUtils";
import { bech32ToHex, getPublicKey, unwrap } from "SnortUtils";
import ZapButton from "Element/Event/ZapButton";
import useImgProxy from "Hooks/useImgProxy";
import Icon from "Icons/Icon";
@ -20,6 +20,7 @@ import Copy from "Element/Copy";
import { delay } from "SnortUtils";
import { PinPrompt } from "Element/PinPrompt";
import useEventPublisher from "Hooks/useEventPublisher";
import { isHex } from "@snort/shared";
declare global {
interface Window {

View File

@ -18,7 +18,7 @@ import {
NostrLink,
UserMetadata,
} from "@snort/system";
import { isOffline } from "@snort/shared";
import { isHex, isOffline } from "@snort/shared";
import { Day } from "Const";
import AnimalName from "Element/User/AnimalName";
@ -152,14 +152,6 @@ export function deepClone<T>(obj: T) {
}
}
export function isHex(s: string) {
// 48-57 = 0-9
// 65-90 = A-Z
// 97-122 = a-z
return [...s]
.map(v => v.charCodeAt(0))
.every(v => (v >= 48 && v <= 57) || (v >= 65 && v <= 90) || v >= 97 || v <= 122);
}
/**
* Simple debounce
*/

View File

@ -1,7 +1,6 @@
import { LNURL } from "@snort/shared";
import { LNURL, isHex } from "@snort/shared";
import { EventPublisher, NostrEvent, NostrLink, SystemInterface } from "@snort/system";
import { generateRandomKey } from "Login";
import { isHex } from "SnortUtils";
import { LNWallet, WalletInvoiceState } from "Wallet";
export interface ZapTarget {