When variable is a money and `$` is used, first 2 chars are removed
andyWynyard opened this issue · 2 comments
ONLY iOS and Safari
Using your regex in the Safari console:
'hello ${ amount }'.replace(new RegExp(
\$\{(?:[\s]+?|\s?)${'amount'}(?:[\s]+?|\s?)}), '$20')
gives
"hello 0"
We have multi locales and a money function that returns the value in either $
£
or €
depending on routing. It works fine on everything except the $
variables.
eg:
t`Hi there, you have ${amount} avaliable`
This will return Hi there, you have £20 available
also €
is fine.
However, with USD it returns Hi there, you have 0 available
omitting the first two characters. This happens on any amount.
So another example if it is $3522
it will show 522
.
Testing this without ttag
it is not broken, so the money function is fine.
Is this a known issue anywhere?
Hi @andyWynyard! Thanks for the report. I guess you have found a bug. Can you provide please some minimal js source file to reproduce the case? Something like: source file, expected result, actual result.
@AlexMost As the edit above indicates, the issue comes from the regex and Safari/iOS handling of these things. The bug goes back to 2008 (as far as we found) with this article. We used one of the workarounds listed.
The above info and the linked article outlining the issue should be what you need.