From: Chris Duncan Date: Sat, 8 Aug 2026 18:53:14 +0000 (-0700) Subject: Pull address pattern matching out of function to module constant. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=dc39f2a387cfb8168cce67000278b69763a24187;p=libnemo.git Pull address pattern matching out of function to module constant. --- diff --git a/src/lib/account/validate.ts b/src/lib/account/validate.ts index 57276b4..23fe218 100644 --- a/src/lib/account/validate.ts +++ b/src/lib/account/validate.ts @@ -5,6 +5,8 @@ import { ALPHABET, PREFIX, PREFIX_LEGACY } from "../constants" import { base32, bytes } from "../convert" import { Blake2b } from "../crypto" +const pattern = new RegExp(`^(${PREFIX}|${PREFIX_LEGACY})[13][${ALPHABET}]{59}$`) + export function _validate (address: unknown): asserts address is string { if (address === undefined) { throw new ReferenceError('Address is undefined.') @@ -12,7 +14,6 @@ export function _validate (address: unknown): asserts address is string { if (typeof address !== 'string') { throw new TypeError('Address must be a string.') } - const pattern = new RegExp(`^(${PREFIX}|${PREFIX_LEGACY})[13]{1}[${ALPHABET}]{59}$`) if (!pattern.test(address)) { throw new RangeError('Invalid address format') }