Fix UA string
This commit is contained in:
parent
35e5eb847a
commit
8b87fe23e2
3 changed files with 28 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue