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);