Move BECH32_REGEX to nip19.ts

This commit is contained in:
Alex Gleason
2023-05-03 14:54:03 -05:00
committed by fiatjaf_
parent 977316915b
commit 1cbb62e6b9
2 changed files with 8 additions and 8 deletions

View File

@@ -5,6 +5,13 @@ import {utf8Decoder, utf8Encoder} from './utils'
const Bech32MaxSize = 5000 const Bech32MaxSize = 5000
/**
* Bech32 regex.
* @see https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32
*/
export const BECH32_REGEX =
/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/
export type ProfilePointer = { export type ProfilePointer = {
pubkey: string // hex pubkey: string // hex
relays?: string[] relays?: string[]

View File

@@ -1,15 +1,8 @@
import * as nip19 from './nip19' import * as nip19 from './nip19'
import * as nip21 from './nip21' import * as nip21 from './nip21'
/**
* Bech32 regex.
* @see https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32
*/
export const BECH32_REGEX =
/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/
/** Nostr URI regex, eg `nostr:npub1...` */ /** Nostr URI regex, eg `nostr:npub1...` */
export const NOSTR_URI_REGEX = new RegExp(`nostr:(${BECH32_REGEX.source})`) export const NOSTR_URI_REGEX = new RegExp(`nostr:(${nip19.BECH32_REGEX.source})`)
/** Test whether the value is a Nostr URI. */ /** Test whether the value is a Nostr URI. */
export function test(value: unknown): value is `nostr:${string}` { export function test(value: unknown): value is `nostr:${string}` {