Dropped storage keys should not cause upload

This commit is contained in:
Fedor Indutny
2022-02-14 11:36:32 -08:00
committed by GitHub
parent 67209d8881
commit a0b05f41e3
6 changed files with 127 additions and 83 deletions
+15 -6
View File
@@ -3,15 +3,24 @@
import type { UUIDStringType } from '../types/UUID';
import { isValidUuid } from '../types/UUID';
import { assert } from './assert';
import type { LoggerType } from '../types/Logging';
import * as log from '../logging/log';
export function normalizeUuid(uuid: string, context: string): UUIDStringType {
export function normalizeUuid(
uuid: string,
context: string,
logger: Pick<LoggerType, 'warn'> = log
): UUIDStringType {
const result = uuid.toLowerCase();
assert(
isValidUuid(uuid) && isValidUuid(result),
`Normalizing invalid uuid: ${uuid} to ${result} in context "${context}"`
);
if (!isValidUuid(uuid) || !isValidUuid(result)) {
logger.warn(
`Normalizing invalid uuid: ${uuid} to ${result} in context "${context}"`
);
// Cast anyway we don't want to throw here
return result as unknown as UUIDStringType;
}
return result;
}