-
-
Notifications
You must be signed in to change notification settings - Fork 203
Normalize CR and CRLF in multi-line strings #754
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses the normalization of multi-line strings by converting CR and CRLF to LF, ensuring consistent line breaks.
- Updated the multi-line scanning in scanner/scanner.go to properly handle CR and CRLF sequences.
- Expanded decode_test.go with test cases covering inputs with CR, CRLF, and LF, verifying normalized outputs.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scanner/scanner.go | Implements CR and CRLF normalization in multi-line strings. |
| decode_test.go | Adds tests for verifying the normalization of line breaks. |
Comments suppressed due to low confidence (2)
scanner/scanner.go:1160
- [nitpick] Consider renaming the variable 'crlf' to 'foundCRLF' for improved clarity on its purpose.
var crlf bool
scanner/scanner.go:1174
- Add an inline comment explaining why subtracting 1 from endPos is necessary when a CRLF is detected, to assist future maintainers in understanding this adjustment.
if crlf { endPos = endPos - 1 }
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #754 +/- ##
==========================================
+ Coverage 77.97% 78.02% +0.04%
==========================================
Files 22 22
Lines 8108 8126 +18
==========================================
+ Hits 6322 6340 +18
Misses 1370 1370
Partials 416 416 🚀 New features to boost your workflow:
|
| s.offset++ | ||
| } | ||
| c = '\n' | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fully confident about this change, since most of the logic is quite similar to what's in the scanNewLine method. I tried to refactor and deduplicate it, but couldn’t come up with a better approach. Open to any suggestions 🙇
Closes #748
Before submitting your PR, please confirm the following.