mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-16 00:49:31 +01:00
25 lines
784 B
Dart
25 lines
784 B
Dart
|
extension MatrixIdentifierStringExtension on String {
|
||
|
/// Separates room identifiers with an event id and possibly a query parameter into its components.
|
||
|
MatrixIdentifierStringExtensionResults parseIdentifierIntoParts() {
|
||
|
final match = RegExp(r'^([#!][^:]*:[^\/?]*)(?:\/(\$[^?]*))?(?:\?(.*))?$')
|
||
|
.firstMatch(this);
|
||
|
if (match == null) {
|
||
|
return null;
|
||
|
}
|
||
|
return MatrixIdentifierStringExtensionResults(
|
||
|
roomIdOrAlias: match.group(1),
|
||
|
eventId: match.group(2),
|
||
|
queryString: match.group(3),
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class MatrixIdentifierStringExtensionResults {
|
||
|
final String roomIdOrAlias;
|
||
|
final String eventId;
|
||
|
final String queryString;
|
||
|
|
||
|
MatrixIdentifierStringExtensionResults(
|
||
|
{this.roomIdOrAlias, this.eventId, this.queryString});
|
||
|
}
|