From 89f618567de7929bb62bffa89f5dc44835a725e3 Mon Sep 17 00:00:00 2001 From: Valdis Thomann Date: Fri, 10 Feb 2023 23:25:46 +1100 Subject: [PATCH] Refine 0xFEED rule --- package.json | 2 +- src/transform.ts | 7 +++++-- test/transform.v3.test.ts | 6 +++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e702597..6458848 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@the-via/reader", - "version": "1.5.8", + "version": "1.5.9", "repository": { "type": "git", "url": "git+ssh://git@github.com/the-via/reader.git" diff --git a/src/transform.ts b/src/transform.ts index 1a35f9a..6e6f05f 100644 --- a/src/transform.ts +++ b/src/transform.ts @@ -23,8 +23,11 @@ export const getVendorProductId = ({ productId, vendorId, }: Pick): number => { - if (productId === '0xFEED' || vendorId === '0xFEED') { - throw new Error(`'0xFEED' is not a valid productId or vendorId.`); + if ( + productId.toUpperCase() === '0XFEED' || + vendorId.toUpperCase() === '0XFEED' + ) { + throw new Error(`'0xFEED' is not a valid vendorId.`); } const parsedVendorId = parseInt(vendorId, 16); diff --git a/test/transform.v3.test.ts b/test/transform.v3.test.ts index a9a978f..6ac5fd8 100644 --- a/test/transform.v3.test.ts +++ b/test/transform.v3.test.ts @@ -46,6 +46,10 @@ test('can transform simple encoder', async () => { test(`Vendor/Product ID of '0xFEED' should fail`, () => { expect(() => getVendorProductId({productId: '0xFEED', vendorId: '0x1234'})) .toThrowErrorMatchingInlineSnapshot(` - "'0xFEED' is not a valid productId or vendorId." + "'0xFEED' is not a valid vendorId." `); + expect(() => getVendorProductId({productId: '0xfeed', vendorId: '0x1234'})) + .toThrowErrorMatchingInlineSnapshot(` + "'0xFEED' is not a valid vendorId." +`); });