[MatrixIdStringExtension] Add null check

This commit is contained in:
Christian Pauly 2020-03-25 13:56:49 +01:00
parent 41cd69548f
commit a2d9bbfc9e
1 changed files with 2 additions and 1 deletions

View File

@ -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();
}