From 6d20fe8d59a77883057b73a9720d5afc1b94742e Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Fri, 20 Dec 2024 14:41:02 +0000 Subject: [PATCH] chore: remove trailing null bytes from printed graffiti (#7320) * chore: remove trailing null bytes from printed graffiti * Use replaceAll instead of regex --- packages/beacon-node/src/util/graffiti.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/beacon-node/src/util/graffiti.ts b/packages/beacon-node/src/util/graffiti.ts index fb5c30aca3d..ff23145d729 100644 --- a/packages/beacon-node/src/util/graffiti.ts +++ b/packages/beacon-node/src/util/graffiti.ts @@ -12,7 +12,9 @@ export function toGraffitiBuffer(graffiti: string): Buffer { * Converts a graffiti from 32 bytes buffer back to a UTF-8 string */ export function fromGraffitiBuffer(graffiti: Uint8Array): string { - return Buffer.from(graffiti.buffer, graffiti.byteOffset, graffiti.byteLength).toString("utf8"); + return Buffer.from(graffiti.buffer, graffiti.byteOffset, graffiti.byteLength) + .toString("utf8") + .replaceAll("\u0000", ""); } export function getDefaultGraffiti(