Skip to content
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

Fix checkboxes in join string #8

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
14 changes: 12 additions & 2 deletions src/pages/string/join/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@ export function mergeText(
joinCharacter: string = ''
): string {
let processedLines: string[] = text.split('\n');

if (deleteTrailingSpaces) {
processedLines = processedLines.map((line) => line.trimEnd());
}

if (deleteBlankLines) {
processedLines = processedLines.filter((line) => line.trim());
processedLines = processedLines.filter((line) => line.trim() !== '');
} else {
processedLines = processedLines.map((line) =>
line.trim() === '' ? line + '\r\n\n' : line
);
}

return processedLines.join(joinCharacter);
}

// Example text to use
`This is a line with trailing spaces
Another line with trailing spaces

Final line without trailing spaces`;
Loading