Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(currencyFilter): trim currency string #15085

Conversation

austinoneil
Copy link
Contributor

@austinoneil austinoneil commented Sep 2, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Bug fix

What is the current behavior? (You can also link to an open issue here)

For certain locales, when the currencySymbol is set to an empty string, there is trailing white space. See issue #15018

What is the new behavior (if this is a feature change)?

Any currency string will be trimmed.

Does this PR introduce a breaking change?

yes

Please check if the PR fulfills these requirements

Other information:

Trim any beginning or trailing white space in a currency string.
Motivation: global fix for issue 15018

Trim any beginning or trailing white space in a currency string.
Motivation: global fix for issue 15018
@austinoneil
Copy link
Contributor Author

Does anybody know how I would change locale for an automated test?

@Narretz
Copy link
Contributor

Narretz commented Sep 5, 2016

You mean in a unit test?

@Narretz Narretz added this to the Backlog milestone Sep 5, 2016
@austinoneil
Copy link
Contributor Author

Yes

On Sep 5, 2016 3:03 PM, "Martin Staffa" notifications@github.com wrote:

You mean in a unit test?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#15085 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AE1cIPvO8OhTDh_WwTjhwv-03Lfqwb_Vks5qnIOKgaJpZM4JzSB6
.

@Narretz
Copy link
Contributor

Narretz commented Sep 6, 2016

Why did you remove the fix from the commit?

@austinoneil
Copy link
Contributor Author

@Narretz The fix is still there. I was just trying things to get a unit test. Check the "files changed" tab.

@Narretz
Copy link
Contributor

Narretz commented Sep 6, 2016

Ah I see, sorry. The test code you changed is a docs end 2 end test, not a unit test though. The filter spec files are in the test folder.

@austinoneil
Copy link
Contributor Author

@Narretz Thanks! Got the unit test in.

@gkalpak
Copy link
Member

gkalpak commented Sep 7, 2016

This does not fix #15018. In fact it just fixes certain cases (i.e. locales which put the currency symbol after the number), but is not a generic fix (see #15018 (comment) for more details).

I am tempted to merge this even if it fixes only some of the cases (as a proper fix is quite more involved), but that would be "unfair" to certain locales :/

@austinoneil
Copy link
Contributor Author

@gkalpak Would appending a .replace(\-/s*\g, '-') fix the potential issue with having a space between the negative sign and the currency amount? I don't see any locale delimiting their currency with anything that would make the fix problematic.

I'll try to add some unit tests and fix based off those when I get home.

@gkalpak
Copy link
Member

gkalpak commented Sep 7, 2016

No, I don't think it would work for all cases (although it would take care of several more than the current implementation). Take into account that people might be overwriting the locals pattern object. E.g. in finance/accounting-related apps people prefer to display negative values wrapped in (...) instead of prefixing them with -.

I have a more general fix. I will submit a PR.

gkalpak added a commit to gkalpak/angular.js that referenced this pull request Sep 7, 2016
In most locales, this won't make a difference (since they do not have whotespace around their
currency symbols). In locales where there is a whitespace separating the currency symbol from the
number, it makes sense to also remove such whitespace if the user specified an empty currency symbol
(indicating they just want the number).

Fixes angular#15018
Closes angular#15085
gkalpak added a commit to gkalpak/angular.js that referenced this pull request Sep 7, 2016
In most locales, this won't make a difference (since they do not have whotespace around their
currency symbols). In locales where there is a whitespace separating the currency symbol from the
number, it makes sense to also remove such whitespace if the user specified an empty currency symbol
(indicating they just want the number).

Fixes angular#15018
Closes angular#15085
gkalpak added a commit that referenced this pull request Dec 19, 2017
In most locales, this won't make a difference (since they do not have
whitespace around their currency symbols). In locales where there is a
whitespace separating the currency symbol from the number, it makes
sense to also remove such whitespace if the user specified an empty
currency symbol (indicating they just want the number).

Fixes #15018
Closes #15085

Closes #15105
@gkalpak gkalpak closed this in 62743a5 Dec 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants