Skip to content

Commit 90e57fa

Browse files
committed
refactor: rename FcmOptions property and verify well formed uri
1 parent 8c4aaa8 commit 90e57fa

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ public void WebpushNotificationWithLinkUrl()
15721572
Body = "body",
15731573
Icon = "icon",
15741574
},
1575-
Options = new WebpushFcmOptions()
1575+
FcmOptions = new WebpushFcmOptions()
15761576
{
15771577
Link = "https://www.firebase.io/",
15781578
},
@@ -1618,7 +1618,7 @@ public void WebpushNotificationWithInvalidLinkUrl()
16181618
Body = "body",
16191619
Icon = "icon",
16201620
},
1621-
Options = new WebpushFcmOptions()
1621+
FcmOptions = new WebpushFcmOptions()
16221622
{
16231623
Link = "http://www.firebase.io/",
16241624
},

FirebaseAdmin/FirebaseAdmin/Messaging/WebpushConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public sealed class WebpushConfig
4848
/// Gets or sets the Webpush options that will be included in the message.
4949
/// </summary>
5050
[JsonProperty("fcm_options")]
51-
public WebpushFcmOptions Options { get; set; }
51+
public WebpushFcmOptions FcmOptions { get; set; }
5252

5353
/// <summary>
5454
/// Copies this Webpush config, and validates the content of it to ensure that it can be
@@ -61,7 +61,7 @@ internal WebpushConfig CopyAndValidate()
6161
Headers = this.Headers?.Copy(),
6262
Data = this.Data?.Copy(),
6363
Notification = this.Notification?.CopyAndValidate(),
64-
Options = this.Options?.CopyAndValidate(),
64+
FcmOptions = this.FcmOptions?.CopyAndValidate(),
6565
};
6666
}
6767
}

FirebaseAdmin/FirebaseAdmin/Messaging/WebpushFcmOptions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ public sealed class WebpushFcmOptions
3535
/// </summary>
3636
internal WebpushFcmOptions CopyAndValidate()
3737
{
38-
if (this.Link != null && !this.Link.StartsWith("https"))
39-
{
40-
throw new ArgumentException("The link options should be a valid https url.");
41-
}
42-
4338
var copy = new WebpushFcmOptions()
4439
{
4540
Link = this.Link,
4641
};
4742

43+
if (copy.Link != null && Uri.IsWellFormedUriString(copy.Link, UriKind.Absolute) && !copy.Link.StartsWith("https"))
44+
{
45+
throw new ArgumentException("The link options should be a valid https url.");
46+
}
47+
4848
return copy;
4949
}
5050
}

0 commit comments

Comments
 (0)