From a2d9bbfc9e6633c922b460b2a1e4dabd84e23cc6 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 25 Mar 2020 13:56:49 +0100 Subject: [PATCH] [MatrixIdStringExtension] Add null check --- lib/src/utils/matrix_id_string_extension.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/utils/matrix_id_string_extension.dart b/lib/src/utils/matrix_id_string_extension.dart index 4064fb9..f25268f 100644 --- a/lib/src/utils/matrix_id_string_extension.dart +++ b/lib/src/utils/matrix_id_string_extension.dart @@ -4,6 +4,7 @@ extension MatrixIdExtension on String { static const int MAX_LENGTH = 255; bool get isValidMatrixId { + if (this?.isEmpty ?? true) return false; if (this.length > MAX_LENGTH) return false; if (!VALID_SIGILS.contains(this.substring(0, 1))) { return false; @@ -22,5 +23,5 @@ extension MatrixIdExtension on String { String get domain => isValidMatrixId ? this.substring(1).split(":")[1] : null; - bool equals(String other) => this.toLowerCase() == other.toLowerCase(); + bool equals(String other) => this?.toLowerCase() == other?.toLowerCase(); }