File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed
Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @solana/connector" ,
3- "version" : " 0.2.3 " ,
3+ "version" : " 0.2.4 " ,
44 "description" : " Headless wallet connector client and React provider built on Wallet Standard" ,
55 "main" : " ./dist/index.js" ,
66 "module" : " ./dist/index.mjs" ,
Original file line number Diff line number Diff line change @@ -243,7 +243,8 @@ describe('Configuration System', () => {
243243 appUrl : 'https://test.com' ,
244244 } ) ;
245245
246- expect ( config . appIdentity . icon ) . toContain ( 'favicon.ico' ) ;
246+ // MWA expects a relative icon path (resolved against appIdentity.uri)
247+ expect ( config . appIdentity . icon ) . toBe ( '/favicon.ico' ) ;
247248 } ) ;
248249 } ) ;
249250
Original file line number Diff line number Diff line change @@ -398,14 +398,31 @@ export function getDefaultMobileConfig(options: {
398398 appUrl ?: string ;
399399 network ?: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet' ;
400400} ) {
401- const baseUrl =
402- options . appUrl || ( typeof window !== 'undefined' ? window . location . origin : 'https://localhost:3000' ) ;
401+ // NOTE: Mobile Wallet Adapter expects `appIdentity.icon` to be a *relative path* (or omitted).
402+ // It resolves this relative path against `appIdentity.uri`.
403+ // @see https://docs.solanamobile.com/mobile-wallet-adapter/web-installation
404+ function getAppOrigin ( appUrl ?: string ) : string {
405+ if ( appUrl ) {
406+ try {
407+ return new URL ( appUrl ) . origin ;
408+ } catch {
409+ // If appUrl is already an origin-like string, use it as-is.
410+ return appUrl ;
411+ }
412+ }
413+ if ( typeof window !== 'undefined' ) return window . location . origin ;
414+ return 'https://localhost:3000' ;
415+ }
416+
417+ const origin = getAppOrigin ( options . appUrl ) ;
403418
404419 return {
405420 appIdentity : {
406421 name : options . appName ,
407- uri : baseUrl ,
408- icon : `${ baseUrl } /favicon.ico` ,
422+ uri : origin ,
423+ // Use a relative icon path so wallets resolve it against `uri`.
424+ // This avoids invalid URLs like: `${uri}/${uri}/favicon.ico` on mobile.
425+ icon : '/favicon.ico' ,
409426 } ,
410427 cluster : options . network || 'mainnet-beta' ,
411428 } ;
You can’t perform that action at this time.
0 commit comments