mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-22 03:39:02 +03:00
22 lines
568 B
TypeScript
22 lines
568 B
TypeScript
import { isValidCameraName } from "./cameraUtil.ts";
|
|
import { generateFixedHash } from "./stringUtil.ts";
|
|
|
|
export function processZoneName(userInput: string): {
|
|
finalZoneName: string;
|
|
friendlyName?: string;
|
|
} {
|
|
const normalizedInput = userInput.replace(/\s+/g, "_").toLowerCase();
|
|
|
|
if (isValidCameraName(normalizedInput)) {
|
|
return {
|
|
finalZoneName: normalizedInput,
|
|
friendlyName: userInput.includes(" ") ? userInput : undefined,
|
|
};
|
|
}
|
|
|
|
return {
|
|
finalZoneName: generateFixedHash(userInput, "zone"),
|
|
friendlyName: userInput,
|
|
};
|
|
}
|