Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When variable is a money and $ is used, first 2 chars are removed #193

Open
andyWynyard opened this issue Jan 7, 2020 · 2 comments
Open

Comments

@andyWynyard
Copy link

andyWynyard commented Jan 7, 2020

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?

@AlexMost
Copy link
Member

AlexMost commented Jan 7, 2020

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.

@andyWynyard
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants