From: Chris Duncan Date: Sun, 12 Jan 2025 22:43:10 +0000 (-0800) Subject: Fix regex for GL arg validation. X-Git-Tag: v1.2.0~7 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=d27d61c30f8baf4411810fcd87fa78ec1561c6d8;p=nano-pow.git Fix regex for GL arg validation. --- diff --git a/src/classes/gl.ts b/src/classes/gl.ts index 1b190da..ab97502 100644 --- a/src/classes/gl.ts +++ b/src/classes/gl.ts @@ -167,7 +167,7 @@ export class NanoPowGl { */ static async search (hash: string, threshold: number = 0xfffffff8): Promise { if (NanoPowGl.#gl == null) throw new Error('WebGL 2 is required') - if (!/^[A-F-a-f0-9]{64}$/.test(hash)) throw new Error(`invalid_hash ${hash}`) + if (!/^[A-Fa-f0-9]{64}$/.test(hash)) throw new Error(`Invalid hash ${hash}`) if (typeof threshold !== 'number') throw new TypeError(`Invalid threshold ${threshold}`) if (this.#gl == null) throw new Error('WebGL 2 is required') @@ -206,8 +206,8 @@ export class NanoPowGl { */ static async validate (work: string, hash: string, threshold: number = 0xfffffff8): Promise { if (NanoPowGl.#gl == null) throw new Error('WebGL 2 is required') - if (!/^[A-F-a-f0-9]{16}$/.test(hash)) throw new Error(`invalid_hash ${work}`) - if (!/^[A-F-a-f0-9]{64}$/.test(hash)) throw new Error(`invalid_hash ${hash}`) + if (!/^[A-Fa-f0-9]{16}$/.test(work)) throw new Error(`Invalid work ${work}`) + if (!/^[A-Fa-f0-9]{64}$/.test(hash)) throw new Error(`Invalid hash ${hash}`) if (typeof threshold !== 'number') throw new TypeError(`Invalid threshold ${threshold}`) if (this.#gl == null) throw new Error('WebGL 2 is required')