From 054a0e57e78276d7e047728872f907b978bbf3fd Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Mon, 29 Apr 2024 18:31:00 +0100 Subject: [PATCH 1/2] perf(index): use `slice()` over `startsWith()` --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 68e223f..f05052d 100644 --- a/src/index.js +++ b/src/index.js @@ -234,7 +234,9 @@ class UnRTF { throw new Error("File missing"); } // Check for RTF specific magic number - if (!buff.toString().startsWith(rtfMagicNumber)) { + if ( + buff.toString().slice(0, rtfMagicNumber.length) !== rtfMagicNumber + ) { throw new Error( "File is not the correct media type, expected 'application/rtf'" ); From 37fcb3b94d0fb95cfa9655ad7ebfdd848f6f006b Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Tue, 30 Apr 2024 13:27:17 +0100 Subject: [PATCH 2/2] test(index): account for arm macs --- src/index.test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.test.js b/src/index.test.js index 750d49c..c65d71d 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -20,7 +20,11 @@ let testBinaryPath; switch (process.platform) { // macOS case "darwin": - testBinaryPath = "/usr/local/bin"; + if (process.arch === "arm64") { + testBinaryPath = "/opt/homebrew/bin"; + } else { + testBinaryPath = "/usr/local/bin"; + } break; case "linux":