application property

String get application

Returns the Config.userAgentProduct with the version parsed from this UserAgent.

Implementation

String get application {
  // If [UserAgent] starts with "Mozilla", then it's probably a browser's
  // `User-Agent` header.
  if (val.startsWith('Mozilla')) {
    return localized;
  }
  // Otherwise it's probably a one generated via [WebUtils.userAgent] method.
  else {
    // Header values are separated by semicolons.
    final List<String> parts = val.split(' ');

    // Values are separated by spaces.
    final List<String> versions = parts.first.split('/');

    if (versions.length == 2) {
      return '${versions[0]} ${versions[1]}';
    }

    // First part should have the name of operating system.
    return parts.first.trim();
  }
}