File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -25,12 +25,20 @@ export function parseMetaMaskUrl(str: string): {
25
25
path : string ;
26
26
} {
27
27
const url = new URL ( str ) ;
28
- const { hostname : authority , pathname : path , protocol } = url ;
28
+ const { protocol } = url ;
29
29
if ( protocol !== 'metamask:' ) {
30
30
throw new Error (
31
31
`Unable to parse URL. Expected the protocol to be "metamask:", but received "${ protocol } ".` ,
32
32
) ;
33
33
}
34
+
35
+ // The browser version of URL differs from the Node version so we rely on the href
36
+ // property to grab the relevant parts of the url instead of hostname and pathname
37
+ const [ authority , ...pathElements ] = url . href
38
+ . replace ( 'metamask://' , '' )
39
+ . split ( '/' ) ;
40
+ const path = `/${ pathElements . join ( '/' ) } ` ;
41
+
34
42
switch ( authority ) {
35
43
case 'client' :
36
44
assert (
You can’t perform that action at this time.
0 commit comments