From 1cbb62e6b9a5a208c407d85ad506c96b5d830a0e Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 3 May 2023 14:54:03 -0500 Subject: [PATCH] Move BECH32_REGEX to nip19.ts --- nip19.ts | 7 +++++++ nip21.ts | 9 +-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nip19.ts b/nip19.ts index f343960..b0f35cc 100644 --- a/nip19.ts +++ b/nip19.ts @@ -5,6 +5,13 @@ import {utf8Decoder, utf8Encoder} from './utils' 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 = { pubkey: string // hex relays?: string[] diff --git a/nip21.ts b/nip21.ts index a5608a2..2411faf 100644 --- a/nip21.ts +++ b/nip21.ts @@ -1,15 +1,8 @@ import * as nip19 from './nip19' 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...` */ -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. */ export function test(value: unknown): value is `nostr:${string}` {