I stumbled upon a string length limitation for the RegExp test method.
In fact, when I want to test whether a string is a valid Base64, I use this script.
const BASETEST = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;
BASETEST.lastIndex = 0;
BASETEST.test(''.padEnd(100,'A'))
// expected output: true
This works fine up until a string length of 4473905. When I want to parse a Base64 string that is longer, a RangeError is returned:
BASETEST.test(''.padEnd(4473906,'A'))
// returns Uncaught RangeError RangeError: Maximum call stack size exceeded at eval (repl:1:6)
Do you agree with me and what would be the way to get this fixed?
This is my very first topic in this group so please be patient with me.
Regards,