Skip to content

Commit fe53be5

Browse files
committed
fix: stop empty note from having a delimiter added to it
1 parent 6f00354 commit fe53be5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/splitter/split-by-delimiter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ export const splitByDelimiter = async (
4343

4444
const splitContent = contentWithoutFrontmatter
4545
.split(escapedDelimiter)
46+
.map((splitContent) => splitContent.trim())
47+
.filter((splitContent) => splitContent !== "")
4648
.map((splitContent) => {
47-
const trimmedContent = splitContent.trim();
4849
if (!removeDelimiter) {
49-
return trimmedContent + delimiter;
50+
return splitContent + delimiter;
5051
}
51-
return trimmedContent;
52-
})
53-
.filter((splitContent) => splitContent !== "");
52+
return splitContent;
53+
});
5454

5555
if (splitContent.length === 1) {
5656
notify("Only one section of content found. Nothing to split.");

test/integration/split-by-delimiter.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ describe("splitByDelimiter", () => {
210210
});
211211

212212
//Assert
213+
expect(mockFileSystem.create).toHaveBeenCalledTimes(2);
213214
expect(mockFileSystem.create).toHaveBeenCalledWith(
214215
expect.stringContaining("split-note"),
215216
"This is sentence 1.",

0 commit comments

Comments
 (0)