From 7b9fca8d0061cf5e5af08cba98e9d5b6dbbed8ec Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 21 Jul 2021 22:00:04 +0200 Subject: Began with better backend error handling & cleaned up the backend --- packages/server/src/api/util.ts | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'packages/server/src/api/util.ts') diff --git a/packages/server/src/api/util.ts b/packages/server/src/api/util.ts index e1eaa2c..e7e7657 100644 --- a/packages/server/src/api/util.ts +++ b/packages/server/src/api/util.ts @@ -26,30 +26,8 @@ export class VerificationResult { message: string | null = null; } -export function verifyRepoName(base_dir: string, repo_name: string): Promise { - return new Promise(resolve => { - console.log(repo_name); - const is_valid_repo_name = (/^[a-zA-Z0-9.\-_]+$/u).test(repo_name); - if(!is_valid_repo_name) { - resolve(new VerificationResult("INVALID", "repository")); - return; - } - - readdir(base_dir, (err, dir_content) => { - if(err) { - resolve(new VerificationResult("NOT_FOUND", "repository")); - return; - } - - const dir_content_repos = dir_content.filter(repo => repo.endsWith(".git")); - if(!dir_content_repos.includes(repo_name + ".git")) { - resolve(new VerificationResult("NOT_FOUND", "repository")); - return; - } - - resolve(new VerificationResult("SUCCESS")); - }); - }); +export function verifyRepoName(repo_name: string): boolean { + return /^[a-zA-Z0-9.\-_]+$/u.test(repo_name); } export async function verifySHA(repository: Repository, sha: string): Promise { -- cgit v1.2.3-18-g5258