Skip to content

Commit

Permalink
feat(github): support github URL or path as query
Browse files Browse the repository at this point in the history
  • Loading branch information
almostSouji committed Mar 7, 2021
1 parent 6d71c2d commit 2e28dad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion model.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"options": [
{
"name": "query",
"description": "Issue, PR number or commit-like expression",
"description": "Issue, PR number, commit-like expression or direct link to a GitHub Issue or PR",
"type": 3,
"required": true
},
Expand Down
8 changes: 8 additions & 0 deletions src/interactions/github/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ function validateGitHubName(name: string): boolean {
}

export async function githubInfo(owner: string, repository: string, expression: string): Promise<Response> {
const re = /(?:https?:\/\/github\.com)?\/?(.*?)\/(.*?)\/.*\/(\d*)/;
const res = re.exec(expression);
if (res) {
const [, o, r, q] = res;
owner = o;
repository = r;
expression = q;
}
if (!validateGitHubName(owner)) {
return new Response(JSON.stringify({
data: {
Expand Down

0 comments on commit 2e28dad

Please sign in to comment.