fix: normalize every CRLF when parsing a RELEASES manifest - #73
Merged
Conversation
String.replace with a string pattern only replaces the first occurrence, so all but the first line of a CRLF manifest kept their trailing \r. The line regex tolerated the stray \r (making this harmless in practice), but the normalization now does what it says via replaceAll. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AtqCsX7ptP36t5rdyaJJhM
There was a problem hiding this comment.
Pull request overview
This PR improves parseRELEASES (Windows Squirrel RELEASES manifest parsing) by ensuring CRLF normalization is applied to all line endings, and adds a regression test intended to cover multi-line CRLF input.
Changes:
- Replace single-occurrence CRLF normalization (
replace) with full normalization (replaceAll) inparseRELEASES. - Add a unit test covering parsing of a multi-line CRLF manifest.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/utils/win-releases.ts |
Uses replaceAll("\r\n", "\n") to fully normalize CRLF before splitting into lines. |
test/unit/win-releases.spec.ts |
Adds a CRLF multi-line parsing test (needs strengthening to actually validate “all CRLFs normalized”). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/utils/win-releases.ts:76
- The comment above this line is factually inverted: it’s
String.prototype.replace("\r\n", "\n")that only replaces the first occurrence;replaceAllis the fix. As written, this is misleading for future readers.
// replaceAll: replace with a string pattern only replaces the first CRLF
const normalizedEOL = stripped.replaceAll("\r\n", "\n");
Copilot review follow-up: the line regex tolerates a trailing CR, so the CRLF test now captures the lines handed to the regex and asserts none still carries one (it fails against first-only String#replace), and the comment no longer reads as if replaceAll were the single-replacement variant. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AtqCsX7ptP36t5rdyaJJhM
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/utils/win-releases.ts:76
- The comment says “replaceAll normalizes every line ending”, but this code only targets CRLF (not standalone
\r). To avoid misleading future readers, consider wording this as normalizing “all CRLF occurrences”.
// String#replace with a string pattern would only replace the first
// CRLF; replaceAll normalizes every line ending
Copilot review follow-up: the RegExp.prototype.exec spy now restores in a finally block so a throwing parseRELEASES can't leak it into later tests; the comments now say only the second (CRLF-terminated) line retains a CR under first-only replacement and that replaceAll targets CRLF occurrences, not every line-ending flavor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AtqCsX7ptP36t5rdyaJJhM
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.
parseRELEASESnormalized line endings withString.replace("\r\n", "\n"), which only replaces the first occurrence — every subsequent line of a CRLF manifest kept its trailing\r. The line regex's[\r]*$tolerance made this harmless in practice, but the normalization now actually does what it says viareplaceAll(string pattern, so the exec-spying edge-case test is unaffected).Adds a multi-line CRLF parsing test.
From the 2.0 release review pass.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AtqCsX7ptP36t5rdyaJJhM
Generated by Claude Code