From 3b7c50438f00e9c4c178475edcc73368aeafdc38 Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Sat, 27 Feb 2021 22:55:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(repos):=20ssh=20url=20=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E8=A7=84=E5=88=99=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=B8=8D=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E8=A6=81=E6=B1=82=E4=BB=85=E6=9C=89=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E6=97=B6=E8=A6=81=E6=B1=82=E8=BF=BD=E5=8A=A0:?= =?UTF-8?q?=E5=88=86=E9=9A=94=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/projects/dtos/create-project.input.ts | 5 ++++- src/repos/repos.service.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/projects/dtos/create-project.input.ts b/src/projects/dtos/create-project.input.ts index d43126b..90ced65 100644 --- a/src/projects/dtos/create-project.input.ts +++ b/src/projects/dtos/create-project.input.ts @@ -3,6 +3,7 @@ import { IsOptional, IsString, IsUrl, + Matches, MaxLength, MinLength, } from 'class-validator'; @@ -19,7 +20,9 @@ export class CreateProjectInput { @MinLength(2) comment: string; - @IsUrl({ protocols: ['ssh'] }) + @Matches( + /^(?:ssh:\/\/)?(?:[\w\d-_]+@)(?:[\w\d-_]+\.)*\w{2,10}(?::\d{1,5})?(?:\/[\w\d-_.]+)*/, + ) @MaxLength(256) sshUrl: string; diff --git a/src/repos/repos.service.ts b/src/repos/repos.service.ts index 4696f72..7561884 100644 --- a/src/repos/repos.service.ts +++ b/src/repos/repos.service.ts @@ -31,7 +31,7 @@ export class ReposService { // TODO: 获取锁,失败抛错。 } - async getGit(project: Project, subDir?: string) { + async getGit(project: Project, subDir = 'default') { const workspaceRoot = this.getWorkspaceRoot(project, subDir); await this.lockWorkspace(workspaceRoot);