Skip to content

Commit

Permalink
[GithubLabels] Support all possible URLs (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitrySharabin authored Jun 24, 2024
1 parent ebd3973 commit b97a126
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions backends/github/labels/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
| ✅ Auth | ✅ Writes | ❌ Uploads |
|---------|-----------|-----------|

**URL format** Either `https://github.com/{owner}/{repo}/labels` or any URL that starts with `https://api.github.com/repos/` and ends with `/labels`
* Labels for a repository: `/repos/{owner}/{repo}/labels`
* Labels for an issue: `/repos/{owner}/{repo}/issues/{issue_number}/labels`
* Labels for issues in a milestone: `/repos/{owner}/{repo}/milestones/{milestone_number}/labels`
**URL format**
* Labels for a repository: `https://github.com/{owner}/{repo}/labels` or `https://api.github.com/repos/{owner}/{repo}/labels`
* Labels for an issue: `https://github.com/{owner}/{repo}/issues/{issue_number}/labels` or `https://api.github.com/repos/{owner}/{repo}/issues/{issue_number}/labels`
* Labels for issues in a milestone: `https://github.com/{owner}/{repo}/milestones/{milestone_number}/labels` or `https://api.github.com/repos/{owner}/{repo}/milestones/{milestone_number}/labels`

Builds on the [Github API](../api/) backend, so it also automatically deals with pagination, just add `max_pages=N` to your URL (where `N` is the number of pages you want to fetch as a maximum). Note this can incur up to `N` HTTP requests, depending on the size of the data.

Expand Down
7 changes: 3 additions & 4 deletions backends/github/labels/github-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import GithubAPI from "../api/github-api.js";
*/
export default class GithubLabels extends GithubAPI {
static urls = [
{hostname: "api.github.com", pathname: "/repos/:owner/:repo/labels"},
{hostname: "api.github.com", pathname: "/repos/:owner/:repo/issues/:issue_number/labels"},
{hostname: "api.github.com", pathname: "/repos/:owner/:repo/milestones/:milestone_number/labels"},
{hostname: "github.com", pathname: "/:owner/:repo/labels"},
{hostname: "(api.)?github.com", pathname: "(/repos)?/:owner/:repo/labels"},
{hostname: "(api.)?github.com", pathname: "(/repos)?/:owner/:repo/issues/:issue_number(.+)?/labels"},
{hostname: "(api.)?github.com", pathname: "(/repos)?/:owner/:repo/milestones/:milestone_number(.+)?/labels"},
];

static phrases = {
Expand Down

0 comments on commit b97a126

Please sign in to comment.