fix: Have matrix id string extension obay the proper grammar
This commit is contained in:
parent
26586b6f02
commit
3d2476cfdb
|
@ -9,8 +9,14 @@ extension MatrixIdExtension on String {
|
|||
if (!VALID_SIGILS.contains(substring(0, 1))) {
|
||||
return false;
|
||||
}
|
||||
// event IDs do not have to have a domain
|
||||
if (substring(0, 1) == '\$') {
|
||||
return true;
|
||||
}
|
||||
// all other matrix IDs have to have a domain
|
||||
final parts = substring(1).split(':');
|
||||
if (parts.length != 2 || parts[0].isEmpty || parts[1].isEmpty) {
|
||||
// the localpart can be an empty string, e.g. for aliases
|
||||
if (parts.length != 2 || parts[1].isEmpty) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -29,9 +29,10 @@ void main() {
|
|||
expect('!test:example.com'.isValidMatrixId, true);
|
||||
expect('+test:example.com'.isValidMatrixId, true);
|
||||
expect('\$test:example.com'.isValidMatrixId, true);
|
||||
expect('\$testevent'.isValidMatrixId, true);
|
||||
expect('test:example.com'.isValidMatrixId, false);
|
||||
expect('@testexample.com'.isValidMatrixId, false);
|
||||
expect('@:example.com'.isValidMatrixId, false);
|
||||
expect('@:example.com'.isValidMatrixId, true);
|
||||
expect('@test:'.isValidMatrixId, false);
|
||||
expect(mxId.sigil, '@');
|
||||
expect('#test:example.com'.sigil, '#');
|
||||
|
|
Loading…
Reference in a new issue