]> git.codecow.com Git - nano25519.git/commitdiff
Fix regular expression anchoring.
authorChris Duncan <chris@zoso.dev>
Wed, 15 Apr 2026 06:50:36 +0000 (23:50 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 15 Apr 2026 06:50:36 +0000 (23:50 -0700)
src/lib/nano25519.ts

index 32a7eb41c60b6f9d0663bba4e0b02778c7440304..c9d6fca22dfb6ebefe7635dc5b15d5756dbfb71a 100644 (file)
@@ -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}`)
                        }