Skip to content

Commit

Permalink
don't pretokenise 0 length strings
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Mar 25, 2024
1 parent ed35987 commit 3e3cf96
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/pretokenise.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@
resultCode = resultCode.substring(0, resultCode.length-5); // remove 'atob('
}
let length = str.length;
if (length<256)
if (length==0) { // it's shorter just to write quotes
resultCode += "";
} else if (length<256)
resultCode += String.fromCharCode(LEX_RAW_STRING8, length) + str;
else if (length<65536)
resultCode += String.fromCharCode(LEX_RAW_STRING16, length&255, (length>>8)&255)+str;
Expand Down

0 comments on commit 3e3cf96

Please sign in to comment.