splitUri method

Map<String?, String?> splitUri()

Implementation

Map<String?, String?> splitUri() {
  String? uri = _description?.url;
  if (uri == null) return {'protocol': null, 'address': null};

  // Regular expression to match the protocol
  RegExp regExp = RegExp(r'^(.*?):\/\/');
  String? protocol;
  String address = uri;

  if (regExp.hasMatch(uri)) {
    protocol = regExp.firstMatch(uri)?.group(1);
    address = uri.replaceFirst(regExp, '');
  }
  return {'protocol': protocol, 'address': address};
}