File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -75,19 +75,20 @@ function validateSubject(subject) {
75
75
+ 'mailto: address. ' + subject ) ;
76
76
}
77
77
78
+ let subjectParseResult = null ;
78
79
try {
79
- const subjectParseResult = new URL ( subject ) ;
80
- if ( ! [ 'https:' , 'mailto:' ] . includes ( subjectParseResult . protocol ) ) {
81
- throw new Error ( 'Vapid subject is not an https: or mailto: URL. ' + subject ) ;
82
- }
83
- if ( subjectParseResult . hostname === 'localhost' ) {
84
- console . warn ( 'Vapid subject points to a localhost web URI, which is unsupported by '
85
- + 'Apple\'s push notification server and will result in a BadJwtToken error when '
86
- + 'sending notifications.' ) ;
87
- }
80
+ subjectParseResult = new URL ( subject ) ;
88
81
} catch ( err ) {
89
82
throw new Error ( 'Vapid subject is not a valid URL. ' + subject ) ;
90
83
}
84
+ if ( ! [ 'https:' , 'mailto:' ] . includes ( subjectParseResult . protocol ) ) {
85
+ throw new Error ( 'Vapid subject is not an https: or mailto: URL. ' + subject ) ;
86
+ }
87
+ if ( subjectParseResult . hostname === 'localhost' ) {
88
+ console . warn ( 'Vapid subject points to a localhost web URI, which is unsupported by '
89
+ + 'Apple\'s push notification server and will result in a BadJwtToken error when '
90
+ + 'sending notifications.' ) ;
91
+ }
91
92
}
92
93
93
94
function validatePublicKey ( publicKey ) {
You can’t perform that action at this time.
0 commit comments