From 3b6a323c432b8d34bed803ef4a979f788b9451d5 Mon Sep 17 00:00:00 2001 From: ricardojdsilva87 Date: Mon, 28 Oct 2024 15:10:44 +0000 Subject: [PATCH] fix: fix api endpoint --- contributor_stats.py | 6 ++++-- contributors.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/contributor_stats.py b/contributor_stats.py index 7ddb36d..1200f65 100644 --- a/contributor_stats.py +++ b/contributor_stats.py @@ -153,10 +153,12 @@ def get_sponsor_information(contributors: list, token: str, ghe: str) -> list: variables = {"username": contributor.username} # Send the GraphQL request - api_endpoint = f"{ghe}/api/v3" if ghe else "https://api.github.com" + api_endpoint = ( + f"{ghe}/api/v3".removeprefix("https://") if ghe else "api.github.com" + ) headers = {"Authorization": f"Bearer {token}"} response = requests.post( - f"{api_endpoint}/graphql", + f"https://{api_endpoint}/graphql", json={"query": query, "variables": variables}, headers=headers, timeout=60, diff --git a/contributors.py b/contributors.py index 102b854..42491c0 100644 --- a/contributors.py +++ b/contributors.py @@ -173,7 +173,7 @@ def get_contributors(repo: object, start_date: str, end_date: str, ghe: str): continue # Store the contributor information in a ContributorStats object - api_endpoint = ghe if ghe else "github.com" + api_endpoint = ghe.removeprefix("https://") if ghe else "github.com" if start_date and end_date: commit_url = f"https://{api_endpoint}/{repo.full_name}/commits?author={user.login}&since={start_date}&until={end_date}" else: