Skip to content

Commit

Permalink
Refine 0xFEED rule
Browse files Browse the repository at this point in the history
  • Loading branch information
ValdisThomann committed Feb 10, 2023
1 parent 1d5cce6 commit 89f6185
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@the-via/reader",
"version": "1.5.8",
"version": "1.5.9",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/the-via/reader.git"
Expand Down
7 changes: 5 additions & 2 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export const getVendorProductId = ({
productId,
vendorId,
}: Pick<KeyboardDefinitionV3, 'productId' | 'vendorId'>): 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);
Expand Down
6 changes: 5 additions & 1 deletion test/transform.v3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."
`);
});

0 comments on commit 89f6185

Please sign in to comment.