During a code review of Pull Request #29, it was discovered that when ParseContent is used to copy content from an empty file, the output contains an unexpected newline character (\n) instead of an empty string. This behavior was observed in the following scenario:
The readers slice passed to ParseContent contains a FileContentReader where the FilePath points to an empty file.
The function returns a string containing only a newline character ("\n") instead of an empty string ("").
Expected Behavior:
When copying content from an empty file, ParseContent should return an empty string to accurately reflect the lack of content in the file.
Proposed Fix:
Add a check within the loop in ParseContent to ensure that the content read from each reader is not empty before appending a newline character and writing it to the strings.Builder.
Additional Notes:
Review the unit tests for ParseContent to ensure they cover the case of empty file input.
Consider adding a test specifically for this scenario to prevent regressions in the future.
During a code review of Pull Request #29, it was discovered that when
ParseContent
is used to copy content from an empty file, the output contains an unexpected newline character (\n
) instead of an empty string. This behavior was observed in the following scenario:readers
slice passed toParseContent
contains aFileContentReader
where theFilePath
points to an empty file."\n"
) instead of an empty string (""
).Expected Behavior:
When copying content from an empty file,
ParseContent
should return an empty string to accurately reflect the lack of content in the file.Proposed Fix:
Add a check within the loop in
ParseContent
to ensure that thecontent
read from each reader is not empty before appending a newline character and writing it to thestrings.Builder
.Additional Notes:
ParseContent
to ensure they cover the case of empty file input._Originally posted by @ccoVeille in https://github.com/supitsdu/clipper/pull/29#discussion_r1657833776_