mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 17:01:13 +00:00
Use graphql in GitHubClient and misc fixes (#8)
* Use graphql in GitHubClient * Replace usage of Array.find with _.find
This commit is contained in:
@@ -7,6 +7,10 @@ export class GitHubUtils {
|
||||
// Custom scheme for github content
|
||||
private static readonly ContentUriPattern = /github:\/\/([^/]*)\/([^/]*)\/([^?]*)\?ref=(.*)/;
|
||||
|
||||
// https://github.com/<owner>/<repo>/blob/<branch>/<path>
|
||||
// We need to support this until we move to newer scheme for quickstarts
|
||||
private static readonly LegacyContentUriPattern = /https:\/\/github.com\/([^/]*)\/([^/]*)\/blob\/([^/]*)\/([^?]*)/;
|
||||
|
||||
public static toRepoFullName(owner: string, repo: string): string {
|
||||
return `${owner}/${repo}`;
|
||||
}
|
||||
@@ -27,7 +31,7 @@ export class GitHubUtils {
|
||||
public static fromContentUri(
|
||||
contentUri: string
|
||||
): undefined | { owner: string; repo: string; branch: string; path: string } {
|
||||
const matches = contentUri.match(GitHubUtils.ContentUriPattern);
|
||||
let matches = contentUri.match(GitHubUtils.ContentUriPattern);
|
||||
if (matches && matches.length > 4) {
|
||||
return {
|
||||
owner: matches[1],
|
||||
@@ -37,6 +41,18 @@ export class GitHubUtils {
|
||||
};
|
||||
}
|
||||
|
||||
matches = contentUri.match(GitHubUtils.LegacyContentUriPattern);
|
||||
if (matches && matches.length > 4) {
|
||||
console.log(`Using legacy github content uri scheme ${contentUri}`);
|
||||
|
||||
return {
|
||||
owner: matches[1],
|
||||
repo: matches[2],
|
||||
branch: matches[3],
|
||||
path: matches[4]
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user