Added sanity check for length of string and corrected -2 to -1.

This commit is contained in:
WickedJack99
2024-04-22 22:00:34 +02:00
parent fcd527160c
commit 8d59b1451a

View File

@@ -37,8 +37,10 @@ public record PeerNotification(Peer sender, Peer receiver) implements Sendable {
fileList += file.getKey() + ",";
}
// Remove last comma
fileList = fileList.substring(0, fileList.length() - 2);
// Remove last comma if fileList contains at least one file that has name of one char
if (fileList.length() >= 2) {
fileList = fileList.substring(0, fileList.length() - 1);
}
String response =
"{\"peer\":\"\"" +