Use synchronous IPC for passing config

This commit is contained in:
Fedor Indutny 2023-04-07 09:42:12 -07:00 committed by GitHub
parent 3e586be46a
commit bd41d7b216
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 87 additions and 97 deletions

View file

@ -1,8 +1,6 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { mapValues } from 'lodash';
export function maybeParseUrl(value: string): undefined | URL {
if (typeof value === 'string') {
try {
@ -20,9 +18,13 @@ export function setUrlSearchParams(
searchParams: Readonly<Record<string, unknown>>
): URL {
const result = cloneUrl(url);
result.search = new URLSearchParams(
mapValues(searchParams, stringifySearchParamValue)
).toString();
result.search = '';
for (const [key, value] of Object.entries(searchParams)) {
if (value == null) {
continue;
}
result.searchParams.append(key, String(value));
}
return result;
}
@ -30,10 +32,6 @@ function cloneUrl(url: Readonly<URL>): URL {
return new URL(url.href);
}
function stringifySearchParamValue(value: unknown): string {
return value == null ? '' : String(value);
}
export function urlPathFromComponents(
components: ReadonlyArray<string>
): string {