Skip to content

Commit 7ca7c80

Browse files
committed
feat: correct importing separator
1 parent 5152226 commit 7ca7c80

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/main/java/one/edee/babylon/entity/MessageFileContent.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,15 @@ public PropertiesMap getMutationProperties(String mutation) {
112112
}
113113

114114
private String normalizeContent(String value) {
115-
String lineSeparator = System.lineSeparator();
116-
if (lineSeparator.equals(IOUtils.LINE_SEPARATOR_WINDOWS))
117-
return value;
118-
return value == null ? null : value.replace(lineSeparator, IOUtils.LINE_SEPARATOR_WINDOWS);
115+
if (value == null)
116+
return null;
117+
118+
// First replace lone \r not followed by \n
119+
value = value.replaceAll("\r(?!\n)", IOUtils.LINE_SEPARATOR_WINDOWS);
120+
121+
// Then replace lone \n not preceded by \r
122+
value = value.replaceAll("(?<!\r)\n", IOUtils.LINE_SEPARATOR_WINDOWS);
123+
return value;
119124
}
120125

121126
public boolean containsKey(String key) {

0 commit comments

Comments
 (0)