mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-11 09:37:37 +03:00
mask util helper function
This commit is contained in:
parent
2a5cf9a533
commit
886a89d1b7
@ -16,6 +16,7 @@ import type {
|
||||
} from "@/types/cameraWizard";
|
||||
import { FaCircleCheck } from "react-icons/fa6";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { maskUri } from "@/utils/cameraUtil";
|
||||
|
||||
type OnvifProbeResultsProps = {
|
||||
isLoading: boolean;
|
||||
@ -258,12 +259,6 @@ function CandidateItem({
|
||||
const { t } = useTranslation(["views/settings"]);
|
||||
const [showFull, setShowFull] = useState(false);
|
||||
|
||||
const maskUri = (uri: string) => {
|
||||
const match = uri.match(/rtsp:\/\/([^:]+):([^@]+)@(.+)/);
|
||||
if (match) return `rtsp://${match[1]}:••••@${match[3]}`;
|
||||
return uri;
|
||||
};
|
||||
|
||||
return (
|
||||
<Card
|
||||
className={cn(
|
||||
|
||||
@ -18,6 +18,7 @@ import { PlayerStatsType } from "@/types/live";
|
||||
import { FaCircleCheck, FaTriangleExclamation } from "react-icons/fa6";
|
||||
import { LuX } from "react-icons/lu";
|
||||
import { Card, CardContent } from "../../ui/card";
|
||||
import { maskUri } from "@/utils/cameraUtil";
|
||||
|
||||
type Step4ValidationProps = {
|
||||
wizardData: Partial<WizardFormData>;
|
||||
@ -374,7 +375,7 @@ export default function Step4Validation({
|
||||
|
||||
<div className="mb-2 flex flex-col justify-between gap-1 md:flex-row md:items-center">
|
||||
<span className="break-all text-sm text-muted-foreground">
|
||||
{stream.url}
|
||||
{maskUri(stream.url)}
|
||||
</span>
|
||||
<Button
|
||||
onClick={() => {
|
||||
|
||||
@ -71,3 +71,16 @@ export async function detectReolinkCamera(
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mask credentials in RTSP URIs for display (e.g., rtsp://user:pass@host -> rtsp://user:••••@host)
|
||||
*/
|
||||
export function maskUri(uri: string): string {
|
||||
try {
|
||||
const match = uri.match(/rtsp:\/\/([^:]+):([^@]+)@(.+)/);
|
||||
if (match) return `rtsp://${match[1]}:${"*".repeat(4)}@${match[3]}`;
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user