From fdebfc0d37b8280f98a37de4159914b8037ec1b8 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Thu, 18 Jun 2026 23:02:33 +0700 Subject: [PATCH] fix: use window.location.href for nostrsigner: URLs instead of window.open(_system) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit window.open(_system) was stripping query parameters from the nostrsigner: URL, causing Amber to receive a request with no type parameter and rejecting it as malformed. window.location.href works correctly in Capacitor WebView — Android intercepts nostrsigner: scheme via intent-filter with full URL intact. Co-authored-by: shakespeare.diy --- src/lib/amber.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/lib/amber.ts b/src/lib/amber.ts index 1648b9c..2691c96 100644 --- a/src/lib/amber.ts +++ b/src/lib/amber.ts @@ -290,18 +290,14 @@ function buildCallbackUrl(): string { /** * Navigate to an Amber nostrsigner: URL. - * In Capacitor WebViews, window.location.href causes a "malformed request" - * error because the WebView tries to navigate instead of firing an intent. - * Use window.open() with _system target to hand off to Android properly. + * + * Use window.location.href for all platforms — Android handles the + * nostrsigner: custom scheme via intent-filter regardless of whether + * we're in a WebView or browser. window.open(_system) was stripping + * query parameters causing Amber to receive a malformed request. */ function openAmberUrl(url: string): void { - // Capacitor / Android WebView: use _system to fire the intent - const isCapacitor = !!(window as unknown as { Capacitor?: { isNativePlatform?: () => boolean } }).Capacitor?.isNativePlatform?.(); - if (isCapacitor) { - window.open(url, '_system'); - } else { - window.location.href = url; - } + window.location.href = url; } /**