mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-28 04:13:18 +01:00
Fix UA string
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import os from 'os';
|
||||
|
||||
import { getOwn } from './getOwn';
|
||||
|
||||
const PLATFORM_STRINGS: { [platform: string]: string } = {
|
||||
@@ -9,12 +11,19 @@ const PLATFORM_STRINGS: { [platform: string]: string } = {
|
||||
linux: 'Linux',
|
||||
};
|
||||
|
||||
export function getUserAgent(appVersion: string): string {
|
||||
export function getUserAgent(
|
||||
appVersion: string,
|
||||
release = os.release()
|
||||
): string {
|
||||
// `process.platform` could be missing if someone figures out how to compile Signal on
|
||||
// an unsupported OS and forgets to update this file. We'd rather send nothing than
|
||||
// crash.
|
||||
const platformString = getOwn(PLATFORM_STRINGS, process.platform);
|
||||
const platformStringWithSpace = platformString ? ` ${platformString}` : '';
|
||||
|
||||
return `Signal-Desktop/${appVersion}${platformStringWithSpace}`;
|
||||
let result = `Signal-Desktop/${appVersion}`;
|
||||
if (platformString) {
|
||||
result += ` ${platformString} ${release}`;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user