Skip to content

Commit 510f446

Browse files
committed
Use length instead of locale for more consistant checking
1 parent 2f1aa67 commit 510f446

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/checks/pii.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ function _tryDecodeBase64(text: string): string | null {
643643
try {
644644
const buffer = Buffer.from(sanitized, 'base64');
645645
if (buffer.length > MAX_DECODED_BYTES) {
646-
throw new Error(`Base64 decoded content too large (${buffer.length.toLocaleString()} bytes). Maximum allowed is 10KB.`);
646+
throw new Error(`Base64 decoded content too large (${buffer.length} bytes). Maximum allowed is 10KB.`);
647647
}
648648
const decoder = new TextDecoder('utf-8', { fatal: true });
649649
return decoder.decode(buffer);
@@ -662,7 +662,7 @@ function _tryDecodeHex(text: string): string | null {
662662
try {
663663
const buffer = Buffer.from(text, 'hex');
664664
if (buffer.length > MAX_DECODED_BYTES) {
665-
throw new Error(`Hex decoded content too large (${buffer.length.toLocaleString()} bytes). Maximum allowed is 10KB.`);
665+
throw new Error(`Hex decoded content too large (${buffer.length} bytes). Maximum allowed is 10KB.`);
666666
}
667667
const decoder = new TextDecoder('utf-8', { fatal: true });
668668
return decoder.decode(buffer);
@@ -685,7 +685,7 @@ function _tryDecodeUrl(text: string): string | null {
685685
const encoder = new TextEncoder();
686686
const length = encoder.encode(decoded).length;
687687
if (length > MAX_DECODED_BYTES) {
688-
throw new Error(`URL decoded content too large (${length.toLocaleString()} bytes). Maximum allowed is 10KB.`);
688+
throw new Error(`URL decoded content too large (${length} bytes). Maximum allowed is 10KB.`);
689689
}
690690
return decoded;
691691
} catch (error) {

0 commit comments

Comments
 (0)