From e7fdc5002ec428e82bacfda0a8f9dd1702805f05 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 30 Sep 2019 15:40:37 +0100 Subject: [PATCH] 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; }