Skip to content

Fix join line scripts not handling Windows CRLF line endings#402

Open
tathagat22 wants to merge 148 commits into
IvanMathy:masterfrom
tathagat22:fix/join-lines-crlf-issue-128
Open

Fix join line scripts not handling Windows CRLF line endings#402
tathagat22 wants to merge 148 commits into
IvanMathy:masterfrom
tathagat22:fix/join-lines-crlf-issue-128

Conversation

@tathagat22
Copy link
Copy Markdown

What

Fixes #128 — all three Join Lines scripts (JoinLines, JoinLinesWithSpace, JoinLinesWithComma) only worked correctly with Unix line endings (\n). Text pasted from Windows apps uses \r\n, which caused the scripts to leave \r characters behind, resulting in broken/partial output.

Why

The original regex /\n/g matches only Unix newlines. Windows line endings are \r\n, so after removing \n, a stray \r (carriage return) remained in the output. This made the joined text appear incorrectly in the editor.

Fix

Changed all three scripts from:

input.text = input.text.replace(/\n/g, '...');

to:

input.text = input.text.replace(/\r\n|\r|\n/g, '...');

This handles all three common line ending styles:

  • Unix: \n
  • Windows: \r\n
  • Legacy Mac: \r

Testing

Verified with Node.js that 4-line text with \r\n endings is now fully joined across all scripts.

IvanMathy and others added 30 commits July 12, 2020 14:40
Hello! A simple script to generate hashtags #cool 😎
Added SHA1, SHA256, and SHA512 algorithms like done for MD5
This script converts data that was serialized by using php's serialize() function into pretty printed json
Add Support for Spongebob Sarcasm Text Script
Added List to HTML and Derpify.js
fix: applicationWillFinishLaunching will prevent Boop from flickering…
IvanMathy and others added 29 commits March 27, 2021 18:51
fix(csvToJson): address CSV complexities
Add script to convert JS arrays/objects to PHP associative array.
Add scripts for converting decimals to hexadecimal strings and decima…
Promoted url script, fixed error, added icon
Promoted sort, added array sorting
…eneratorScript

Script: Generate Project Glossary Markdown file
Supporting SF Symbols identifiers for script icons
Adding CalculateSize.js script to calc size of input.text in bytes
Yes, this means development is becoming more active again.
…vanMathy#128)

The three Join Lines scripts used /\n/g which only matched Unix line
endings. Text pasted from Windows apps uses \r\n, leaving \r characters
behind and causing incorrect output. Updated all three scripts to use
/\r\n|\r|\n/g so they handle Unix, Windows, and legacy Mac line endings.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

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.