Skip to content

fix: handle Auto delimiter in fromDecimal (#2217)#2308

Open
OndraDol wants to merge 1 commit intogchq:masterfrom
OndraDol:fix/issue-2217
Open

fix: handle Auto delimiter in fromDecimal (#2217)#2308
OndraDol wants to merge 1 commit intogchq:masterfrom
OndraDol:fix/issue-2217

Conversation

@OndraDol
Copy link
Copy Markdown

@OndraDol OndraDol commented Apr 4, 2026

Summary

Fixes the fromDecimal() function to correctly handle the Auto delimiter mode. Utils.charRep("Auto") returns undefined, causing data.split(undefined) to treat the entire input as a single element and only parse the first decimal value.

Changes

  • Use regex /[^\d-]+/ to split on any non-digit, non-minus character when delimiter is "Auto", consistent with how fromHex() handles its Auto mode
  • Added test cases for Auto delimiter with comma, colon, and semicolon separators

Related Issue

Closes #2217

Testing

  • Verified fix with space, comma, colon, and semicolon separators
  • Verified signed value support still works
  • Verified explicit delimiter mode is unaffected
  • ESLint passes clean

Comment on lines +535 to +539
it("From decimal with Auto delimiter", () => {
assert.strictEqual(chef.fromDecimal("72,101,108,108,111").toString(), "Hello");
assert.strictEqual(chef.fromDecimal("72:101:108:108:111").toString(), "Hello");
assert.strictEqual(chef.fromDecimal("72;101;108;108;111").toString(), "Hello");
}),
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.

Would you mind adding a test to check the functionality of handling negative numbers? From reading your code, I believe that the output of chef.fromDecimal("-72 101 108 -108 -111") would be [-72, 101, 108, -108, -111] and it would be good to confirm whether that is or is not the case in a test.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Successfully merging this pull request may close these issues.

Bug report: fromDecimal(...) function does not correctly handle delim parameter passed as default ("Auto")

3 participants