From ca050d7990234f0c63eee252f36289aa3c8c34d3 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Thu, 22 Jul 2021 15:18:38 -0700 Subject: [PATCH] Fallback to displaying full user-agent string if a pretty version cannot be determined --- web/utils/format.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/utils/format.ts b/web/utils/format.ts index 81c4a1938..8ceea6e01 100644 --- a/web/utils/format.ts +++ b/web/utils/format.ts @@ -55,6 +55,12 @@ export function formatUAstring(uaString: string) { const { major: browserVersion, name } = browser; const { version: osVersion, name: osName } = os; const { model, type } = device; + + // Fallback to just displaying the raw agent string. + if (!name || !browserVersion || !osName) { + return uaString; + } + const deviceString = model || type ? ` (${model || type})` : ''; return `${name} ${browserVersion} on ${osName} ${osVersion} ${deviceString}`;