fix: _detectLineBreakStyle never returned 'CRLF' - #70
Open
bermudezmt wants to merge 1 commit into
Open
Conversation
_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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_detectLineBreakStylecould 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\npairs 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:
lineBreakStyleis a reporting property and does not affect segment counts, encoding, or billing math.Added unit tests that assert
lineBreakStyledirectly 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/anddocs/scripts/bundles. Per theCLAUDE.mdconvention in this repo, these are committed deployed artifacts:dist/is the npm package output, anddocs/scripts/are the webpack bundles for the browser demo. The fix lives insrc/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