normalizeRoomStorageAttachmentPath function
Implementation
String normalizeRoomStorageAttachmentPath(String path) {
final trimmedPath = path.trim();
if (trimmedPath.isEmpty) {
return "";
}
final uri = Uri.tryParse(trimmedPath);
if (uri != null && uri.scheme == "room") {
return [
if (uri.host.trim().isNotEmpty) uri.host.trim(),
...uri.pathSegments.map((segment) => segment.trim()).where((segment) => segment.isNotEmpty),
].join("/");
}
return trimmedPath.replaceFirst(RegExp(r"^/+"), "");
}