Files
Genarrative/apps/preview-deployer-web/src/validation.ts
T
kdletters 41874ab391
Project CI / Repository checks (push) Successful in 1m16s
Project CI / Frontend tests (push) Successful in 3m1s
Project CI / Backend tests (push) Successful in 4m2s
Project CI / Native shell tests (push) Successful in 17m2s
新增内网容器预览部署控制面
新增分支与指定提交的预览部署 SPA 和 Jenkins 代理服务
新增多实例 Docker 预览流水线、端口租约、实时健康状态和卸载能力
新增 /build 内网路由、systemd 部署资产和运维文档
修正容器 Nginx 健康检查探针
2026-08-15 17:18:10 +08:00

28 lines
672 B
TypeScript

const BRANCH_PATTERN = /^[0-9A-Za-z._/-]+$/u;
const COMMIT_PATTERN = /^[0-9a-fA-F]{7,40}$/u;
export function validateBranch(value: string) {
const branch = value.trim();
if (!branch) {
return '请输入分支名';
}
if (
branch.length > 200 ||
!BRANCH_PATTERN.test(branch) ||
branch.startsWith('/') ||
branch.endsWith('/') ||
branch.includes('..')
) {
return '分支名格式不正确';
}
return '';
}
export function validateCommitHash(value: string) {
const commitHash = value.trim();
if (commitHash && !COMMIT_PATTERN.test(commitHash)) {
return 'Commit Hash 需为 7 到 40 位十六进制字符';
}
return '';
}