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

Adds check for empty thousands separator #1089

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pivot.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ callWithJQuery ($) ->
x1 = x[0]
x2 = if x.length > 1 then decimalSep + x[1] else ''
rgx = /(\d+)(\d{3})/
x1 = x1.replace(rgx, '$1' + thousandsSep + '$2') while rgx.test(x1)
x1 = x1.replace(rgx, '$1' + thousandsSep + '$2') while rgx.test(x1) if thousandsSep
return x1 + x2

numberFormat = (opts) ->
Expand Down
5 changes: 5 additions & 0 deletions tests/pivot_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,11 @@ describe "$.pivotUtilities", ->
expect nf 1234567.89123456
.toEqual "1a234a567b89"

it "adds blank thousands separator", ->
nf = numberFormat(thousandsSep: "", decimalSep: "b")
expect nf 1234567.89123456
.toEqual "1234567b89"

it "adds prefixes and suffixes", ->
nf = numberFormat(prefix: "a", suffix: "b")
expect nf 1234567.89123456
Expand Down