Skip to content

Fix regression in lib/clean_number#1184

Closed
etpinard wants to merge 2 commits into
masterfrom
clean-datum-regression
Closed

Fix regression in lib/clean_number#1184
etpinard wants to merge 2 commits into
masterfrom
clean-datum-regression

Conversation

@etpinard

Copy link
Copy Markdown
Contributor

- junk in the 'middle' of numeric string is again accepted
@etpinard etpinard added status: reviewable bug something broken labels Nov 21, 2016
Comment thread src/lib/clean_number.js
var FRONTJUNK = /^['"%,$#\s']+/;
var ENDJUNK = /['"%,$#\s']+$/;
// precompile for speed
var JUNK = /['"%,$#\s]/g;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread test/jasmine/tests/lib_test.js Outdated
['2 2', 22],
['2%2', 22],
['2$2', 22],
['1,690,000', 1690000]

@chriddyp chriddyp Nov 21, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add one for '$5,162,000.00' to 5162000?

@chriddyp chriddyp Nov 21, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: " $1,410,000.00 " to 1410000?

Comment thread test/jasmine/tests/lib_test.js Outdated
['2 2', 22],
['2%2', 22],
['2$2', 22],
['1,690,000', 1690000]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that this is what we had before - which is exactly why I changed it, though obviously I forgot about commas in the middle! I really think we should consider interpreting '2 2', '2%2', '2$2' etc as numbers to be bugs we should fix, unless someone can show me a legitimate use case for them to be interpreted as 22.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about '1 000 000' ?

@alexcjohnson

Copy link
Copy Markdown
Collaborator

Since we're reverting this to buy us some time... lets do this right. Can we do:
var JUNK = /(^['"%,$#\s]|,|['"%,$#\s]/g
ie strip only commas in the middle, and all these other characters on the ends?

@etpinard etpinard closed this Nov 22, 2016
@etpinard
etpinard deleted the clean-datum-regression branch November 22, 2016 14:35
@etpinard

Copy link
Copy Markdown
Contributor Author

Closed in favour of #1185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug something broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

certain data input strings lead to broken plots.

3 participants