Skip to content

Commit a75278e

Browse files
committed
Make suggested changes
1 parent 8112b55 commit a75278e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

extensions/ql-vscode/src/databaseFetcher.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export async function promptImportLgtmDatabase(
108108
}
109109

110110
export async function retrieveCanonicalRepoName(lgtmUrl: string) {
111-
const givenRepoName = parseLgtmUrl(lgtmUrl);
111+
const givenRepoName = extractProjectSlug(lgtmUrl);
112112
const response = await checkForFailingResponse(await fetch(`https://api.github.com/repos/${givenRepoName}`), 'Failed to locate the repository on github');
113113
const repo = await response.json();
114114
if (!repo || !repo.full_name) {
@@ -419,9 +419,9 @@ function convertRawLgtmSlug(maybeSlug: string): string | undefined {
419419
return;
420420
}
421421

422-
function parseLgtmUrl(lgtmUrl: string): string | undefined {
422+
function extractProjectSlug(lgtmUrl: string): string | undefined {
423423
// Only matches the '/g/' provider (github)
424-
const re = new RegExp('https://lgtm.com/projects/g/(.*)');
424+
const re = new RegExp('https://lgtm.com/projects/g/(.*[^/])');
425425
const match = lgtmUrl.match(re);
426426
if (!match) {
427427
return;
@@ -441,12 +441,12 @@ export async function convertToDatabaseUrl(
441441
// fallback check for github repos with same name but different case
442442
let canonicalName = await retrieveCanonicalRepoName(lgtmUrl);
443443
if (!canonicalName) {
444-
throw new Error();
444+
throw new Error('Repository not found.');
445445
}
446446
canonicalName = convertRawLgtmSlug(`g/${canonicalName}`);
447447
projectJson = await downloadLgtmProjectMetadata(canonicalName);
448448
if (projectJson.code === 404) {
449-
throw new Error();
449+
throw new Error('Failed to download project from LGTM.');
450450
}
451451
}
452452

0 commit comments

Comments
 (0)