refactor: arbitrary components in _parseIdentifierIntoUri

This commit is contained in:
Lukas Lihotzki 2021-09-23 13:15:28 +02:00 committed by Krille Fear
parent fb0ea2efc3
commit 3b1c6e3d2b
1 changed files with 6 additions and 7 deletions

View File

@ -91,14 +91,13 @@ extension MatrixIdExtension on String {
(m) => Uri.encodeComponent(m.group(0)))) (m) => Uri.encodeComponent(m.group(0))))
.replaceAll('#', '%23')); .replaceAll('#', '%23'));
} else { } else {
final match =
RegExp(r'^([#!@+][^:]*:[^\/?]*)(?:\/(\$[^?]*))?(?:\?(.*))?$')
.firstMatch(this);
if (match == null) return null;
return Uri( return Uri(
pathSegments: pathSegments: RegExp(r'/((?:[#!@+][^:]*:)?[^/?]*)(?:\?.*$)?')
[match.group(1), match.group(2)].where((x) => x != null), .allMatches('/$this')
query: match.group(3)); .map((m) => m.group(1)),
query: RegExp(r'(?:/(?:[#!@+][^:]*:)?[^/?]*)*\?(.*$)')
.firstMatch('/$this')
?.group(1));
} }
} }