将后端迁入 backend/,完善根目录 .gitignore,删除误提交的 .mypy_cache 缓存文件。 Co-authored-by: Cursor <cursoragent@cursor.com>
15 lines
367 B
Python
15 lines
367 B
Python
"""RTSP URL 日志脱敏。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
_RTSP_CRED_RE = re.compile(r"(?P<scheme>rtsp://)(?P<userinfo>[^@/\s]+@)")
|
|
|
|
|
|
def redact_rtsp_url(url: str | None) -> str:
|
|
"""把 ``rtsp://user:pwd@host/...`` 脱敏为 ``rtsp://***@host/...``。"""
|
|
if not url:
|
|
return ""
|
|
return _RTSP_CRED_RE.sub(r"\g<scheme>***@", url)
|