Skip to content

Commit

Permalink
fix: Imgur links not being previewed and extra extension sometimes be…
Browse files Browse the repository at this point in the history
…ing added (Sk1erLLC#169)

* Fix Imgur links not previewing & extra extension being added

* Remove unused import

Added this when debugging the issue and i forgor to remove 💀
  • Loading branch information
GamingGeek authored and Wyvest committed Mar 10, 2024
1 parent 92609f1 commit fa2efbe
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void handle(String value) {
return;
}

if (value.contains("imgur.com/")) {
if (value.contains("imgur.com/") && !value.contains("i.imgur")) {
final String[] split = value.split("/");
value = String.format("https://i.imgur.com/%s.png", split[split.length - 1]);
}
Expand Down Expand Up @@ -158,6 +158,10 @@ private void loadUrl(String url) {
connection.setUseCaches(true);
connection.setInstanceFollowRedirects(true);
connection.addRequestProperty("User-Agent", "Patcher Image Previewer");
if (url.contains("imgur")) {
// Prevents redirect to main website
connection.addRequestProperty("Referer", "https://imgur.com/");
}
connection.setReadTimeout(15000);
connection.setConnectTimeout(15000);
connection.setDoOutput(true);
Expand Down

0 comments on commit fa2efbe

Please sign in to comment.