From 02513075a117572e8f0ef160297e8ba1ae693bba Mon Sep 17 00:00:00 2001 From: "Imam A. Fahrezi" Date: Sat, 26 Apr 2025 11:15:01 +0700 Subject: [PATCH] refactor: optimize SANITIZE.manual to remove unnecessary template literal --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7d874bc..17c4d2e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -178,10 +178,10 @@ const findEscapeSequence = /["\b\t\n\v\f\r\/]/ const SANITIZE = { auto: (property: string) => `${findEscapeSequence}.test(${property})?JSON.stringify(${property}).slice(1,-1):${property}`, - manual: (property: string) => `${property}`, + manual: (property: string) => property, // Remove unnecessary template literal throw: (property: string) => `${findEscapeSequence}.test(${property})?(()=>{throw new Error("Property '${property}' contains invalid characters")})():${property}` -} satisfies Record string> + } satisfies Record string> const joinStringArray = (p: string) => `"$\{` +