From 8ec48c508a835aee1623c616354ec40a7e5131cf Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Wed, 17 Apr 2024 14:44:22 -0700
Subject: [PATCH] fix hex parsing
---
www/src/ts/utils.ts | 16 ++++++++++------
www/src/ts/virtual_machine/device.ts | 2 +-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/www/src/ts/utils.ts b/www/src/ts/utils.ts
index 594b0ed..033f4b8 100644
--- a/www/src/ts/utils.ts
+++ b/www/src/ts/utils.ts
@@ -181,9 +181,11 @@ export function parseNumber(s: string): number {
if (/^\$[0-9A-Fa-f]+$/.test(s)) {
return parseInt(s.slice(1), 16)
}
- const hex = parseHex(s);
- if (!isNaN(hex)) {
- return hex;
+ if (/[a-fA-F]/.test(s)) {
+ const hex = parseHex(s);
+ if (!isNaN(hex)) {
+ return hex;
+ }
}
return parseFloat(s);
}
@@ -204,9 +206,11 @@ export function parseIntWithHexOrBinary(s: string): number {
if (/^\$[0-9A-Fa-f]+$/.test(s)) {
return parseInt(s.slice(1), 16)
}
- const hex = parseHex(s);
- if (!isNaN(hex)) {
- return hex;
+ if (/[a-fA-F]/.test(s)) {
+ const hex = parseHex(s);
+ if (!isNaN(hex)) {
+ return hex;
+ }
}
return parseInt(s);
}
diff --git a/www/src/ts/virtual_machine/device.ts b/www/src/ts/virtual_machine/device.ts
index 71c0ac7..2b7c022 100644
--- a/www/src/ts/virtual_machine/device.ts
+++ b/www/src/ts/virtual_machine/device.ts
@@ -460,7 +460,7 @@ export class VMDeviceList extends BaseElement {
protected render(): HTMLTemplateResult {
const deviceCards: HTMLTemplateResult[] = this.filteredDeviceIds.map(
(id, _index, _ids) =>
- html`< vm - device - card.deviceID=${ id } class="device-list-card" > `,
+ html`