From fffc1fac5ae6eb87ad556ff7e1ce8337279f7464 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:45:24 -0400 Subject: Fix: Brave Downloads Cutting `host` (#2761) --- .../hannibal2/skyhanni/tweaker/DownloadSourceChecker.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/tweaker/DownloadSourceChecker.java b/src/main/java/at/hannibal2/skyhanni/tweaker/DownloadSourceChecker.java index 7947b6ebc..8596b5fb2 100644 --- a/src/main/java/at/hannibal2/skyhanni/tweaker/DownloadSourceChecker.java +++ b/src/main/java/at/hannibal2/skyhanni/tweaker/DownloadSourceChecker.java @@ -13,6 +13,8 @@ import java.io.FileReader; import java.net.URI; import java.net.URL; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class DownloadSourceChecker { @@ -78,9 +80,20 @@ public class DownloadSourceChecker { } )); + // Compile the regex pattern for matching an empty host + Pattern pattern = Pattern.compile("https:\\/\\/.*.com\\/$|about:internet"); + Matcher matcher = pattern.matcher(uriToSimpleString(host)); + + // Check if the host is empty (Brave is cutting everything past .com/ from the host) + String cutHostMessage = ""; + if (matcher.find()) { + cutHostMessage = "\n\nYour browser MAY have interfered with the download process.\n" + + "Try downloading the file using a different browser (Microsoft Edge, Google Chrome, etc.)."; + } + JOptionPane.showOptionDialog( frame, - String.format(String.join("\n", SECURITY_POPUP), uriToSimpleString(host)), + String.format(String.join("\n", SECURITY_POPUP), uriToSimpleString(host)) + cutHostMessage, "SkyHanni " + MOD_VERSION + " Security Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, -- cgit