File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
FirebaseAdmin.Tests/Messaging Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -1605,7 +1605,7 @@ public void WebpushNotificationWithLinkUrl()
16051605 }
16061606
16071607 [ Fact ]
1608- public void WebpushNotificationWithInvalidLinkUrl ( )
1608+ public void WebpushNotificationWithInvalidHttpLinkUrl ( )
16091609 {
16101610 var message = new Message ( )
16111611 {
@@ -1627,6 +1627,29 @@ public void WebpushNotificationWithInvalidLinkUrl()
16271627 Assert . Throws < ArgumentException > ( ( ) => message . CopyAndValidate ( ) ) ;
16281628 }
16291629
1630+ [ Fact ]
1631+ public void WebpushNotificationWithInvalidHttpsLinkUrl ( )
1632+ {
1633+ var message = new Message ( )
1634+ {
1635+ Topic = "test-topic" ,
1636+ Webpush = new WebpushConfig ( )
1637+ {
1638+ Notification = new WebpushNotification ( )
1639+ {
1640+ Title = "title" ,
1641+ Body = "body" ,
1642+ Icon = "icon" ,
1643+ } ,
1644+ FcmOptions = new WebpushFcmOptions ( )
1645+ {
1646+ Link = "https whatever" ,
1647+ } ,
1648+ } ,
1649+ } ;
1650+ Assert . Throws < ArgumentException > ( ( ) => message . CopyAndValidate ( ) ) ;
1651+ }
1652+
16301653 private void AssertJsonEquals ( JObject expected , Message actual )
16311654 {
16321655 var json = NewtonsoftJsonSerializer . Instance . Serialize ( actual . CopyAndValidate ( ) ) ;
Original file line number Diff line number Diff line change @@ -40,9 +40,12 @@ internal WebpushFcmOptions CopyAndValidate()
4040 Link = this . Link ,
4141 } ;
4242
43- if ( copy . Link != null && Uri . IsWellFormedUriString ( copy . Link , UriKind . Absolute ) && ! copy . Link . StartsWith ( "https" ) )
43+ if ( copy . Link != null )
4444 {
45- throw new ArgumentException ( "The link options should be a valid https url." ) ;
45+ if ( ! Uri . IsWellFormedUriString ( copy . Link , UriKind . Absolute ) || ! copy . Link . StartsWith ( "https" ) )
46+ {
47+ throw new ArgumentException ( "The link options should be a valid https url." ) ;
48+ }
4649 }
4750
4851 return copy ;
You can’t perform that action at this time.
0 commit comments