@@ -352,13 +352,14 @@ export async function findDirWithFile(
352352
353353/**
354354 * The URL pattern is https://lgtm.com/projects/{provider}/{org}/{name}/{irrelevant-subpages}.
355- * There are several possibilities for the provider: in addition to GitHub.com(g),
355+ * There are several possibilities for the provider: in addition to GitHub.com (g),
356356 * LGTM currently hosts projects from Bitbucket (b), GitLab (gl) and plain git (git).
357357 *
358- * After the {provider}/{org}/{name} path components, there may be the components
359- * related to sub pages.
358+ * This function accepts any url that matches the pattern above. It also accepts the
359+ * raw project slug, e.g., `g/myorg/myproject`
360360 *
361- * This function accepts any url that matches the patter above
361+ * After the `{provider}/{org}/{name}` path components, there may be the components
362+ * related to sub pages.
362363 *
363364 * @param lgtmUrl The URL to the lgtm project
364365 *
@@ -370,6 +371,10 @@ export function looksLikeLgtmUrl(lgtmUrl: string | undefined): lgtmUrl is string
370371 return false ;
371372 }
372373
374+ if ( convertRawLgtmSlug ( lgtmUrl ) ) {
375+ return true ;
376+ }
377+
373378 try {
374379 const uri = Uri . parse ( lgtmUrl , true ) ;
375380 if ( uri . scheme !== 'https' ) {
@@ -387,9 +392,23 @@ export function looksLikeLgtmUrl(lgtmUrl: string | undefined): lgtmUrl is string
387392 }
388393}
389394
395+ function convertRawLgtmSlug ( maybeSlug : string ) : string | undefined {
396+ if ( ! maybeSlug ) {
397+ return ;
398+ }
399+ const segments = maybeSlug . split ( '/' ) ;
400+ const providers = [ 'g' , 'gl' , 'b' , 'git' ] ;
401+ if ( segments . length === 3 && providers . includes ( segments [ 0 ] ) ) {
402+ return `https://lgtm.com/projects/${ maybeSlug } ` ;
403+ }
404+ return ;
405+ }
406+
390407// exported for testing
391408export async function convertToDatabaseUrl ( lgtmUrl : string ) {
392409 try {
410+ lgtmUrl = convertRawLgtmSlug ( lgtmUrl ) || lgtmUrl ;
411+
393412 const uri = Uri . parse ( lgtmUrl , true ) ;
394413 const paths = [ 'api' , 'v1.0' ] . concat (
395414 uri . path . split ( '/' ) . filter ( ( segment ) => segment )
0 commit comments