From e7fdc5002ec428e82bacfda0a8f9dd1702805f05 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 30 Sep 2019 15:40:37 +0100 Subject: [PATCH 1/2] Guard against falsy names in getInitialLetter This ensures we check for a falsy name in `getInitialLetter` instead of throwing errors. We should perhaps also fix whatever other issues have led to the input being undefined in the first place, but for now we leave this for another day. Hopefully helps with https://github.com/vector-im/riot-web/issues/10983 --- src/Avatar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avatar.js b/src/Avatar.js index 2e15874b4e..23e5fab9fb 100644 --- a/src/Avatar.js +++ b/src/Avatar.js @@ -67,7 +67,7 @@ module.exports = { * @return {string} the first letter */ getInitialLetter(name) { - if (name.length < 1) { + if (!name || name.length < 1) { return undefined; } From 762e0111fb188dbe39988943a0cdc231c6677560 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 30 Sep 2019 16:00:58 +0100 Subject: [PATCH 2/2] Add trace as well --- src/Avatar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Avatar.js b/src/Avatar.js index 23e5fab9fb..17860698cb 100644 --- a/src/Avatar.js +++ b/src/Avatar.js @@ -67,7 +67,12 @@ module.exports = { * @return {string} the first letter */ getInitialLetter(name) { - if (!name || name.length < 1) { + if (!name) { + // XXX: We should find out what causes the name to sometimes be falsy. + console.trace("`name` argument to `getInitialLetter` not supplied"); + return undefined; + } + if (name.length < 1) { return undefined; }