@@ -43,19 +43,25 @@ const focusOrOpenWindow = function (url) {
43
43
return true
44
44
}
45
45
46
+ const isProtocolHandled = ( protocol ) => {
47
+ protocol = ( protocol || '' ) . split ( ':' ) [ 0 ]
48
+ return navigatableTypes . includes ( protocol ) ||
49
+ electron . session . defaultSession . protocol . isNavigatorProtocolHandled ( protocol )
50
+ }
51
+
46
52
// Checks an array of arguments if it can find a url
47
53
const getUrlFromCommandLine = ( argv ) => {
48
54
if ( argv ) {
49
55
if ( argv . length === 2 && ! argv [ 1 ] . startsWith ( '-' ) ) {
50
56
const parsedUrl = urlParse ( argv [ 1 ] )
51
- if ( navigatableTypes . includes ( parsedUrl . protocol ) ) {
57
+ if ( isProtocolHandled ( parsedUrl . protocol ) ) {
52
58
return argv [ 1 ]
53
59
}
54
60
}
55
61
const index = argv . indexOf ( '--' )
56
62
if ( index !== - 1 && index + 1 < argv . length && ! argv [ index + 1 ] . startsWith ( '-' ) ) {
57
63
const parsedUrl = urlParse ( argv [ index + 1 ] )
58
- if ( navigatableTypes . includes ( parsedUrl . protocol ) ) {
64
+ if ( isProtocolHandled ( parsedUrl . protocol ) ) {
59
65
return argv [ index + 1 ]
60
66
}
61
67
}
@@ -68,7 +74,7 @@ if (!isDarwin) {
68
74
const openUrl = getUrlFromCommandLine ( process . argv )
69
75
if ( openUrl ) {
70
76
const parsedUrl = urlParse ( openUrl )
71
- if ( navigatableTypes . includes ( parsedUrl . protocol ) ) {
77
+ if ( isProtocolHandled ( parsedUrl . protocol ) ) {
72
78
module . exports . newWindowURL = openUrl
73
79
}
74
80
}
@@ -101,7 +107,7 @@ app.on('will-finish-launching', () => {
101
107
app . on ( 'open-url' , ( event , path ) => {
102
108
event . preventDefault ( )
103
109
const parsedUrl = urlParse ( path )
104
- if ( navigatableTypes . includes ( parsedUrl . protocol ) ) {
110
+ if ( isProtocolHandled ( parsedUrl . protocol ) ) {
105
111
if ( ! focusOrOpenWindow ( path ) ) {
106
112
module . exports . newWindowURL = path
107
113
}
0 commit comments