From: Chris Duncan Date: Wed, 15 Apr 2026 06:50:36 +0000 (-0700) Subject: Fix regular expression anchoring. X-Git-Tag: v1.0.2~2 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=c78a2fc154d2704d9dd5f45f644dbd26387f3470;p=nano25519.git Fix regular expression anchoring. --- diff --git a/src/lib/nano25519.ts b/src/lib/nano25519.ts index 32a7eb4..c9d6fca 100644 --- a/src/lib/nano25519.ts +++ b/src/lib/nano25519.ts @@ -150,7 +150,7 @@ const nano25519_init = (bytes: number[]): { derive: typeof derive, sign: typeof throw new TypeError(`Invalid byte length for ${name}`) } if (typeof value === 'string') { - const regex = RegExp(`[A-Fa-f0-9]{${byteLengthMin << 1},${byteLengthMax << 1}}`) + const regex = RegExp(`^[A-Fa-f0-9]{${byteLengthMin << 1},${byteLengthMax << 1}}$`) if (!regex.test(value)) { throw new TypeError(`Invalid ${name} ${value}`) }