Skip to content

Commit

Permalink
fix: *.github.comでTokenを送りつける。
Browse files Browse the repository at this point in the history
Closes #73
  • Loading branch information
PeyaPeyaPeyang committed Apr 7, 2022
1 parent e1784d3 commit 2b2ae86
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static Pair<Integer, String> postAsString(String urlString, String data,
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
if (url.getHost().equals("api.github.com"))
if (url.getHost().endsWith("github.com") || url.getHost().equals("raw.githubusercontent.com"))
connection.setRequestProperty(
"Authorization",
"token " + TeamKunPluginManager.getPlugin().getVault().getToken()
Expand Down Expand Up @@ -82,7 +82,7 @@ public static Pair<Integer, String> getAsString(String urlString)
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
if (url.getHost().equals("api.github.com") &&
if ((url.getHost().endsWith("github.com") || url.getHost().equals("raw.githubusercontent.com")) &&
!TeamKunPluginManager.getPlugin().getVault().getToken().isEmpty())
connection.setRequestProperty(
"Authorization",
Expand Down Expand Up @@ -161,7 +161,7 @@ public static Pair<Boolean, String> downloadFile(String url, String fileName)

connection.setRequestMethod("GET");
connection.setInstanceFollowRedirects(false);
if (urlObj.getHost().equals("api.github.com"))
if (urlObj.getHost().endsWith("github.com") || urlObj.getHost().equals("raw.githubusercontent.com"))
connection.setRequestProperty(
"Authorization",
"token " + TeamKunPluginManager.getPlugin().getVault().getToken()
Expand Down Expand Up @@ -230,7 +230,7 @@ public static int fetch(String urlString, String method)
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(method);
if (url.getHost().equals("api.github.com"))
if (url.getHost().endsWith("github.com") || url.getHost().equals("raw.githubusercontent.com"))
connection.setRequestProperty(
"Authorization",
"token " + TeamKunPluginManager.getPlugin().getVault().getToken()
Expand Down

0 comments on commit 2b2ae86

Please sign in to comment.