diff options
author | HampusM <hampus@hampusmat.com> | 2021-07-21 22:00:04 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-07-21 22:00:04 +0200 |
commit | 7b9fca8d0061cf5e5af08cba98e9d5b6dbbed8ec (patch) | |
tree | 2a75dfaaa495c90e5519012e2c8e20ab0bd7ac4e /packages/server/src/api/util.ts | |
parent | c0eb6635964de276b44851df67fb857ae94dc401 (diff) |
Began with better backend error handling & cleaned up the backend
Diffstat (limited to 'packages/server/src/api/util.ts')
-rw-r--r-- | packages/server/src/api/util.ts | 26 |
1 files changed, 2 insertions, 24 deletions
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<VerificationResult> { - return new Promise<VerificationResult>(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<VerificationResult> { |