normalizeAddress static method

String normalizeAddress(
  1. String? address, {
  2. APIConfig? apiConfig,
})

Implementation

static String normalizeAddress(String? address, {APIConfig? apiConfig}) {
  address ??= apiConfig?.getPath('server', 'address');

  address = address?.trim() ?? '';

  if (address == '*' ||
      address == '0' ||
      address == '::' ||
      address == '0:0:0:0:0:0:0:0') {
    return '0.0.0.0';
  }

  if (address.isEmpty ||
      address == 'local' ||
      address == '1' ||
      address == '127' ||
      address == '::1' ||
      address == '0:0:0:0:0:0:0:1') {
    return 'localhost';
  }

  return address;
}