diff --git a/src/main/java/club/sk1er/patcher/screen/render/overlay/ImagePreview.java b/src/main/java/club/sk1er/patcher/screen/render/overlay/ImagePreview.java index 6eeb20b54..22a2f919f 100644 --- a/src/main/java/club/sk1er/patcher/screen/render/overlay/ImagePreview.java +++ b/src/main/java/club/sk1er/patcher/screen/render/overlay/ImagePreview.java @@ -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]); } @@ -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);