Merge branch 'soru/update-matrix-scheme' into 'main'
chore: Update matrix scheme parsing to match updated MSC See merge request famedly/famedlysdk!657
This commit is contained in:
commit
62ad8569ae
|
|
@ -97,11 +97,10 @@ extension MatrixIdExtension on String {
|
||||||
final identifiers = <String>[];
|
final identifiers = <String>[];
|
||||||
for (var i = 0; i < pathSegments.length - 1; i += 2) {
|
for (var i = 0; i < pathSegments.length - 1; i += 2) {
|
||||||
final thisSigil = {
|
final thisSigil = {
|
||||||
'user': '@',
|
'u': '@',
|
||||||
'roomid': '!',
|
'roomid': '!',
|
||||||
'room': '#',
|
'r': '#',
|
||||||
'group': '+',
|
'e': '\$',
|
||||||
'event': '\$',
|
|
||||||
}[pathSegments[i].toLowerCase()];
|
}[pathSegments[i].toLowerCase()];
|
||||||
if (thisSigil == null) {
|
if (thisSigil == null) {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -88,26 +88,23 @@ void main() {
|
||||||
.parseIdentifierIntoParts();
|
.parseIdentifierIntoParts();
|
||||||
expect(res.via, <String>{'fox.com', 'fox.org'});
|
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.primaryIdentifier, '@her:example.org');
|
||||||
expect(res.secondaryIdentifier, null);
|
expect(res.secondaryIdentifier, null);
|
||||||
res = 'matrix:user/bad'.parseIdentifierIntoParts();
|
res = 'matrix:u/bad'.parseIdentifierIntoParts();
|
||||||
expect(res, null);
|
expect(res, null);
|
||||||
res = 'matrix:roomid/rid:example.org'.parseIdentifierIntoParts();
|
res = 'matrix:roomid/rid:example.org'.parseIdentifierIntoParts();
|
||||||
expect(res.primaryIdentifier, '!rid:example.org');
|
expect(res.primaryIdentifier, '!rid:example.org');
|
||||||
expect(res.secondaryIdentifier, null);
|
expect(res.secondaryIdentifier, null);
|
||||||
expect(res.action, 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.primaryIdentifier, '#us:example.org');
|
||||||
expect(res.secondaryIdentifier, null);
|
expect(res.secondaryIdentifier, null);
|
||||||
expect(res.action, 'chat');
|
expect(res.action, 'chat');
|
||||||
res = 'matrix:room/us:example.org/event/lol823y4bcp3qo4'
|
res = 'matrix:r/us:example.org/e/lol823y4bcp3qo4'
|
||||||
.parseIdentifierIntoParts();
|
.parseIdentifierIntoParts();
|
||||||
expect(res.primaryIdentifier, '#us:example.org');
|
expect(res.primaryIdentifier, '#us:example.org');
|
||||||
expect(res.secondaryIdentifier, '\$lol823y4bcp3qo4');
|
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'
|
res = 'matrix:roomid/rid:example.org?via=fox.com&via=fox.org'
|
||||||
.parseIdentifierIntoParts();
|
.parseIdentifierIntoParts();
|
||||||
expect(res.primaryIdentifier, '!rid:example.org');
|
expect(res.primaryIdentifier, '!rid:example.org');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue