From 68457c5e7e8e37be2edf7eaffc8a51ec334991ce Mon Sep 17 00:00:00 2001 From: Miguel Alatzar Date: Thu, 20 Aug 2020 11:55:09 -0700 Subject: [PATCH] Use substring over replaceFirst (#4707) --- .../java/com/mattermost/rnbeta/CustomPushNotification.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.java b/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.java index 8bf1c47471..9145500092 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.java @@ -534,7 +534,12 @@ public class CustomPushNotification extends PushNotification { } private String removeSenderNameFromMessage(String message, String senderName) { - return message.replaceFirst(senderName, "").replaceFirst(": ", "").trim(); + Integer index = message.indexOf(senderName); + if (index == 0) { + message = message.substring(senderName.length()); + } + + return message.replaceFirst(": ", "").trim(); } private void notificationReceiptDelivery(String ackId, String postId, String type, boolean isIdLoaded, ResolvePromise promise) {