getNamespace static method

String? getNamespace(
  1. String channel
)

Get the namespace of a channel

Implementation

static String? getNamespace(String channel) {
  if (!channel.startsWith('/')) {
    return null;
  }

  final segments = channel.split('/').where((s) => s.isNotEmpty).toList();

  if (segments.isEmpty) {
    return '/';
  }

  return '/${segments.first}';
}