Function toBestFittingType produces wrong results on 64-bit prototype
The toBestFittingType
function produces wrong results on the 64-bit prototype, returning string inputs like adsfasfas
as undefined.
The problem is the regex for matching numbers: on the 64-bit prototype it wrongly identifies everything as a number. This does not happen in the normal 32-bit version. Whether this is due to a change from the underlying platform or the difference in the compilation of 32-bit vs 64-bit is unknown.
After some tests this seems to be tied with using three groups to check for different numbers. When they are split into three separate regex checks it seems to work correctly.
Original regex which produces wrong results on 64-bit prototype:
regex("^(-?(0|([1-9][0-9]*)|([0-9]+\\.[0-9]*))(cm)?)$", trimmedInput)
Split into three regex checks:
regex("^(-?0(cm)?)$", trimmedInput)
OR regex("^(-?[1-9][0-9]*(cm)?)$", trimmedInput)
OR regex("^(-?[0-9]+[.][0-9]*(cm)?)$", trimmedInput)