Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

fix: keep Linux auth navigation in the current window

Jhon Supelanoc66c7f4c7bbf
diff --git a/src-tauri/src/inject/event.js b/src-tauri/src/inject/event.js
index 03342f5f..c8b9ac44 100644
--- a/src-tauri/src/inject/event.js
+++ b/src-tauri/src/inject/event.js
@@ -591,7 +591,10 @@ function shouldBypassPakeLinkHandling(rawHref) {
}
function shouldNavigateAuthInCurrentWindow() {
- return /macintosh|mac os x/i.test(navigator.userAgent);
+ // WKWebView can abort on auth popups, while WebKitGTK may return a truthy
+ // proxy even when the native side denies the window. Keep those platforms
+ // in-place without changing the working WebView2 popup path on Windows.
+ return /mac|linux/i.test(getDesktopPlatform());
}
function canNavigateAuthUrl(url) {
diff --git a/tests/unit/event-link-guard.test.js b/tests/unit/event-link-guard.test.js
index 42ae7e84..1ef5021f 100644
--- a/tests/unit/event-link-guard.test.js
+++ b/tests/unit/event-link-guard.test.js
@@ -378,6 +378,49 @@ describe("event link guard", () => {
expect(result).toBe(window);
});
+ it("navigates Linux auth URLs in the current window", () => {
+ const { openAuthNavigation, window } = loadEventHelpers({
+ userAgent: "Mozilla/5.0 (X11; Linux x86_64)",
+ });
+ const originalWindowOpen = vi.fn(() => ({}));
+
+ const result = openAuthNavigation(
+ originalWindowOpen,
+ "https://accounts.google.com/o/oauth2/auth",
+ "_blank",
+ "width=1200,height=800",
+ );
+
+ expect(originalWindowOpen).not.toHaveBeenCalled();
+ expect(window.location.href).toBe(
+ "https://accounts.google.com/o/oauth2/auth",
+ );
+ expect(result).toBe(window);
+ });
+
+ it("keeps Windows auth URLs on the native popup path", () => {
+ const popup = {};
+ const { openAuthNavigation, window } = loadEventHelpers({
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
+ });
+ const originalWindowOpen = vi.fn(() => popup);
+
+ const result = openAuthNavigation(
+ originalWindowOpen,
+ "https://accounts.google.com/o/oauth2/auth",
+ "_blank",
+ "width=1200,height=800",
+ );
+
+ expect(originalWindowOpen).toHaveBeenCalledWith(
+ "https://accounts.google.com/o/oauth2/auth",
+ "_blank",
+ "width=1200,height=800",
+ );
+ expect(window.location.href).toBe("https://example.com/app");
+ expect(result).toBe(popup);
+ });
+
it("keeps blank macOS auth popups on the native popup path", () => {
const popup = {};
const { openAuthNavigation, window } = loadEventHelpers({