just format

This commit is contained in:
Alex Gleason
2023-08-31 13:42:15 -05:00
parent 2a70bb18ff
commit 718032022c
55 changed files with 930 additions and 1488 deletions

View File

@@ -1,14 +1,11 @@
import {BECH32_REGEX, decode, type DecodeResult} from './nip19.ts'
import { BECH32_REGEX, decode, type DecodeResult } from './nip19.ts'
/** Nostr URI regex, eg `nostr:npub1...` */
export const NOSTR_URI_REGEX = new RegExp(`nostr:(${BECH32_REGEX.source})`)
/** Test whether the value is a Nostr URI. */
export function test(value: unknown): value is `nostr:${string}` {
return (
typeof value === 'string' &&
new RegExp(`^${NOSTR_URI_REGEX.source}$`).test(value)
)
return typeof value === 'string' && new RegExp(`^${NOSTR_URI_REGEX.source}$`).test(value)
}
/** Parsed Nostr URI data. */
@@ -28,6 +25,6 @@ export function parse(uri: string): NostrURI {
return {
uri: match[0] as `nostr:${string}`,
value: match[1],
decoded: decode(match[1])
decoded: decode(match[1]),
}
}