diff --git a/src/main/java/vslab1/src/Sending/Data/PeerNotification.java b/src/main/java/vslab1/src/Sending/Data/PeerNotification.java index 25836cb..c22a7e8 100644 --- a/src/main/java/vslab1/src/Sending/Data/PeerNotification.java +++ b/src/main/java/vslab1/src/Sending/Data/PeerNotification.java @@ -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\":\"\"" +