chore: Update matrix scheme parsing to match updated MSC

This commit is contained in:
Sorunome 2021-02-23 16:34:43 +01:00
parent 82f823f50e
commit e7c8e754a1
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
2 changed files with 7 additions and 11 deletions

View File

@ -97,11 +97,10 @@ extension MatrixIdExtension on String {
final identifiers = <String>[];
for (var i = 0; i < pathSegments.length - 1; i += 2) {
final thisSigil = {
'user': '@',
'u': '@',
'roomid': '!',
'room': '#',
'group': '+',
'event': '\$',
'r': '#',
'e': '\$',
}[pathSegments[i].toLowerCase()];
if (thisSigil == null) {
break;

View File

@ -88,26 +88,23 @@ void main() {
.parseIdentifierIntoParts();
expect(res.via, <String>{'fox.com', 'fox.org'});
res = 'matrix:user/her:example.org'.parseIdentifierIntoParts();
res = 'matrix:u/her:example.org'.parseIdentifierIntoParts();
expect(res.primaryIdentifier, '@her:example.org');
expect(res.secondaryIdentifier, null);
res = 'matrix:user/bad'.parseIdentifierIntoParts();
res = 'matrix:u/bad'.parseIdentifierIntoParts();
expect(res, null);
res = 'matrix:roomid/rid:example.org'.parseIdentifierIntoParts();
expect(res.primaryIdentifier, '!rid:example.org');
expect(res.secondaryIdentifier, null);
expect(res.action, null);
res = 'matrix:room/us:example.org?action=chat'.parseIdentifierIntoParts();
res = 'matrix:r/us:example.org?action=chat'.parseIdentifierIntoParts();
expect(res.primaryIdentifier, '#us:example.org');
expect(res.secondaryIdentifier, null);
expect(res.action, 'chat');
res = 'matrix:room/us:example.org/event/lol823y4bcp3qo4'
res = 'matrix:r/us:example.org/e/lol823y4bcp3qo4'
.parseIdentifierIntoParts();
expect(res.primaryIdentifier, '#us:example.org');
expect(res.secondaryIdentifier, '\$lol823y4bcp3qo4');
res = 'matrix:group/them:example.org'.parseIdentifierIntoParts();
expect(res.primaryIdentifier, '+them:example.org');
expect(res.secondaryIdentifier, null);
res = 'matrix:roomid/rid:example.org?via=fox.com&via=fox.org'
.parseIdentifierIntoParts();
expect(res.primaryIdentifier, '!rid:example.org');