signal-desktop/ts/util/normalizeUuid.ts

15 lines
369 B
TypeScript
Raw Normal View History

2021-06-22 07:46:42 -07:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2021-10-26 15:59:08 -07:00
import { isValidUuid } from '../types/UUID';
2021-06-22 16:08:55 -07:00
import { assert } from './assert';
2021-06-22 07:46:42 -07:00
export function normalizeUuid(uuid: string, context: string): string {
2021-06-22 16:08:55 -07:00
assert(
2021-10-26 15:59:08 -07:00
isValidUuid(uuid),
2021-06-22 16:08:55 -07:00
`Normalizing invalid uuid: ${uuid} in context "${context}"`
);
2021-06-22 07:46:42 -07:00
return uuid.toLowerCase();
}