signal-desktop/ts/util/isMockServer.ts
andrew-signal 9c99796937
Update libsignal to v0.59.0, add support for mock server test with libsignal
Co-authored-by: trevor-signal <trevor@signal.org>
Co-authored-by: Fedor Indutny <indutny@signal.org>
2024-10-21 12:27:58 -07:00

18 lines
415 B
TypeScript

// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export function isMockServer(
serverUrl = window.SignalContext.config.serverUrl
): boolean {
try {
const url = new URL(serverUrl);
return (
url.hostname === 'localhost' ||
url.hostname === '127.0.0.1' ||
url.hostname === '[::1]' // IPv6 loopback address
);
} catch (e) {
return false;
}
}