Skip to content

Commit

Permalink
don't use JSON.stringify twice
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanGaignault committed Jul 23, 2024
1 parent c0c0ed1 commit ff5491e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/tools/serialisation/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export function sanitize(source: unknown, maxCharacterCount = SANITIZE_DEFAULT_M
containerQueue,
visitedObjectsWithPath
)
let accumulatedCharacterCount = JSON.stringify(sanitizedData) ? JSON.stringify(sanitizedData).length : 0
const serializedSanitizedData = JSON.stringify(sanitizedData)
let accumulatedCharacterCount = serializedSanitizedData ? serializedSanitizedData.length : 0

if (accumulatedCharacterCount > maxCharacterCount) {
warnOverCharacterLimit(maxCharacterCount, 'discarded', source)
Expand Down

0 comments on commit ff5491e

Please sign in to comment.