From 42f4d5a52bcaaeba3784ccb7f65ffb6d33bc3b02 Mon Sep 17 00:00:00 2001 From: Made4Uo Date: Sun, 23 Jun 2024 15:44:34 -0700 Subject: [PATCH 1/2] Fix checkboxes in join string --- src/components/ToolsExamples.tsx | 0 src/pages/string/join/service.ts | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/components/ToolsExamples.tsx diff --git a/src/components/ToolsExamples.tsx b/src/components/ToolsExamples.tsx new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/string/join/service.ts b/src/pages/string/join/service.ts index e636238..b736dd6 100644 --- a/src/pages/string/join/service.ts +++ b/src/pages/string/join/service.ts @@ -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`; From bb34fee40ccfe06829b9df058944d579ee2e0290 Mon Sep 17 00:00:00 2001 From: "Ibrahima G. Coulibaly" Date: Sun, 23 Jun 2024 23:55:30 +0100 Subject: [PATCH 2/2] Revert "Fix checkboxes in join string" --- src/components/ToolsExamples.tsx | 0 src/pages/string/join/service.ts | 14 ++------------ 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 src/components/ToolsExamples.tsx diff --git a/src/components/ToolsExamples.tsx b/src/components/ToolsExamples.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/string/join/service.ts b/src/pages/string/join/service.ts index b736dd6..e636238 100644 --- a/src/pages/string/join/service.ts +++ b/src/pages/string/join/service.ts @@ -5,23 +5,13 @@ 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() !== ''); - } else { - processedLines = processedLines.map((line) => - line.trim() === '' ? line + '\r\n\n' : line - ); + processedLines = processedLines.filter((line) => line.trim()); } + 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`;