Skip to content

fix: _detectLineBreakStyle never returned 'CRLF' - #70

Open
bermudezmt wants to merge 1 commit into
mainfrom
fix/DEVED-14139-crlf-linebreak-detection
Open

fix: _detectLineBreakStyle never returned 'CRLF'#70
bermudezmt wants to merge 1 commit into
mainfrom
fix/DEVED-14139-crlf-linebreak-detection

Conversation

@bermudezmt

@bermudezmt bermudezmt commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

_detectLineBreakStyle could never return 'CRLF'. Because '\r\n' contains '\n', any pure-CRLF message was detected as mixed and labeled 'LF+CRLF', leaving the 'CRLF' branch as unreachable dead code.

The fix detects a lone LF by stripping \r\n pairs before testing for a remaining '\n', so the three styles are mutually exclusive and 'CRLF' is reachable. Pure-CRLF input now reports 'CRLF' instead of 'LF+CRLF'.

This is display-only: lineBreakStyle is a reporting property and does not affect segment counts, encoding, or billing math.

Added unit tests that assert lineBreakStyle directly for no-break, LF, CRLF, and mixed input. The existing tests only checked character counts, which is why the mislabeling went unnoticed. The new CRLF test fails against the old code.


Note on built artifacts (@gverni):

This PR includes rebuilt dist/ and docs/scripts/ bundles. Per the CLAUDE.md convention in this repo, these are committed deployed artifacts: dist/ is the npm package output, and docs/scripts/ are the webpack bundles for the browser demo. The fix lives in src/libs/SegmentedMessage.ts, and both artifact sets embed that code, so they're rebuilt together to keep the repo in a consistent state. The source change itself is small (one method, 4 new tests), but the built artifacts make the diff look larger. Would love your thoughts on whether this convention still makes sense, or if we should move to building artifacts only at release time.


Closes #67

_detectLineBreakStyle could never return 'CRLF': because '\r\n'
contains '\n', a pure-CRLF message was detected as mixed and labeled
'LF+CRLF'. Detect a lone LF by stripping CRLF pairs before testing for
'\n', so the three styles are mutually exclusive and 'CRLF' is reachable.

Add unit tests asserting lineBreakStyle for no-break, LF, CRLF, and
mixed input. Rebuild dist/ and docs/scripts/ bundles.

Closes #67
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: _detectLineBreakStyle never returns 'CRLF' (unreachable branch)

1 participant