From e7c8e754a18c59a28c1b7b6fa59ca9cbe5979d48 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Tue, 23 Feb 2021 16:34:43 +0100 Subject: [PATCH] chore: Update matrix scheme parsing to match updated MSC --- lib/src/utils/matrix_id_string_extension.dart | 7 +++---- test/matrix_id_string_extension_test.dart | 11 ++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/src/utils/matrix_id_string_extension.dart b/lib/src/utils/matrix_id_string_extension.dart index 83cd00aa..281f7060 100644 --- a/lib/src/utils/matrix_id_string_extension.dart +++ b/lib/src/utils/matrix_id_string_extension.dart @@ -97,11 +97,10 @@ extension MatrixIdExtension on String { final identifiers = []; 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; diff --git a/test/matrix_id_string_extension_test.dart b/test/matrix_id_string_extension_test.dart index c3d1d61e..69575ba1 100644 --- a/test/matrix_id_string_extension_test.dart +++ b/test/matrix_id_string_extension_test.dart @@ -88,26 +88,23 @@ void main() { .parseIdentifierIntoParts(); expect(res.via, {'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');