Casts a raw string (e.g. a query param or form field) into a typed value -
number, boolean, null/undefined, or an array of strings.
Ported from luv-autoq-frontend's copy, which fixed a regex state-leak bug
still present in bws-checkout-service-spa's copy: hasLettersPattern and
whiteSpacePattern used to carry the global (g) regex flag. A regex with
g keeps .lastIndex state between .test() calls, so mixed
alphanumeric input (e.g. "1a", "12a34") was inconsistently miscast to a
number or NaN depending on how many times the pattern had already been
tested. Neither pattern needs g here - both are always tested from the
start of the string - so the flag is simply dropped.
Casts a raw string (e.g. a query param or form field) into a typed value - number, boolean,
null/undefined, or an array of strings.Ported from
luv-autoq-frontend's copy, which fixed a regex state-leak bug still present inbws-checkout-service-spa's copy:hasLettersPatternandwhiteSpacePatternused to carry the global (g) regex flag. A regex withgkeeps.lastIndexstate between.test()calls, so mixed alphanumeric input (e.g."1a","12a34") was inconsistently miscast to a number orNaNdepending on how many times the pattern had already been tested. Neither pattern needsghere - both are always tested from the start of the string - so the flag is simply dropped.