From 0705f4b182cf681f3725e3ffa2b32ae7b4de4d01 Mon Sep 17 00:00:00 2001
From: Simon Ser <contact@emersion.fr>
Date: Thu, 10 Jun 2021 08:49:17 +0200
Subject: [PATCH] lib/client: always populate prefix for incoming messages

---
 lib/client.js | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/client.js b/lib/client.js
index f53a890..2974854 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -158,6 +158,14 @@ export default class Client extends EventTarget {
 		if (!msg.prefix) {
 			msg.prefix = this.serverPrefix;
 		}
+		// Some servers send e.g. NOTICE messages before RPL_WELCOME
+		if (!msg.prefix) {
+			msg.prefix = {
+				name: null,
+				user: null,
+				host: null,
+			};
+		}
 
 		var msgBatch = null;
 		if (msg.tags["batch"]) {