From f7594efa61522654f8d8e1bdfa41af8084cc33ba Mon Sep 17 00:00:00 2001
From: Adhidarma Hadiwinoto <me@adhisimon.org>
Date: Mon, 31 Oct 2016 18:03:33 +0700
Subject: [PATCH] toLowerCase

---
 matrix-util.js | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/matrix-util.js b/matrix-util.js
index d21fbf1..ce9142a 100644
--- a/matrix-util.js
+++ b/matrix-util.js
@@ -24,7 +24,9 @@ function MatrixUtil(options) {
 }
 
 MatrixUtil.prototype.updateBuddyState = function(jid, state, statusText, resource) {
+    if (!jid) {return; }
     if (jid == 'undefined') {return; }
+    jid = jid.toLowerCase();
 
     let logger = this.logger;
     let matrix = this.matrix;
@@ -65,6 +67,9 @@ MatrixUtil.prototype.updateBuddyState = function(jid, state, statusText, resourc
 }
 
 MatrixUtil.prototype.isAFriend = function(jid) {
+    if (!jid) { return; }
+    jid = jid.toLowerCase();
+
     let matrix = this.matrix;
 
     if (!matrix) { return false; };
@@ -75,6 +80,9 @@ MatrixUtil.prototype.isAFriend = function(jid) {
 }
 
 MatrixUtil.prototype.isPartnerOffline = function(partner) {
+    if (!partner) { return; }
+    partner = partner.toLowerCase();
+
     let matrix = this.matrix;
     let logger = this.logger;
 
@@ -97,6 +105,9 @@ MatrixUtil.prototype.isPartnerOffline = function(partner) {
 }
 
 MatrixUtil.prototype.updateLastIncoming = function(sender, msg) {
+    if (!sender) { return; }
+    sender = sender.toLowerCase();
+
     let matrix = this.matrix;
 
     if (!matrix) {
@@ -118,6 +129,9 @@ MatrixUtil.prototype.updateLastIncoming = function(sender, msg) {
 }
 
 MatrixUtil.prototype.updateLastOutgoing = function(destination, msg) {
+    if (!destination) { return; }
+    destination = destination.toLowerCase();
+    
     let matrix = this.matrix;
 
     if (!matrix) {
-- 
1.9.0