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) {
7575 + 'mailto: address. ' + subject ) ;
7676 }
7777
78+ let subjectParseResult = null ;
7879 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 ) ;
8881 } catch ( err ) {
8982 throw new Error ( 'Vapid subject is not a valid URL. ' + subject ) ;
9083 }
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+ }
9192}
9293
9394function validatePublicKey ( publicKey ) {
You can’t perform that action at this time.
0 commit comments