Skip to content

Commit 9f69a63

Browse files
committed
Convert to camelCase
1 parent 4d30152 commit 9f69a63

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/PuppeteerSharp.Tests/NavigationTests/PageGotoTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ await Task.WhenAll(
507507
Server.WaitForRequest("/digits/1.png", r => referer2 = r.Headers["Referer"]),
508508
Page.GoToAsync(TestConstants.ServerUrl + "/grid.html", new NavigationOptions
509509
{
510-
ReferrerPolicy = "no-referer"
510+
ReferrerPolicy = "no-referrer"
511511
})
512512
);
513513

lib/PuppeteerSharp/Cdp/CdpFrame.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
using System;
2424
using System.Collections.Generic;
25+
using System.Text.RegularExpressions;
2526
using System.Threading.Tasks;
2627
using Microsoft.Extensions.Logging;
2728
using PuppeteerSharp.Cdp.Messaging;
@@ -114,7 +115,7 @@ async Task NavigateAsync()
114115
{
115116
Url = url,
116117
Referrer = referrer ?? string.Empty,
117-
ReferrerPolicy = referrerPolicy,
118+
ReferrerPolicy = ReferrerPolicyToProtocol(referrerPolicy),
118119
FrameId = Id,
119120
}).ConfigureAwait(false);
120121

@@ -335,4 +336,12 @@ internal void UpdateClient(CDPSession client, bool keepWorlds = false)
335336
/// <inheritdoc />
336337
protected internal override DeviceRequestPromptManager GetDeviceRequestPromptManager()
337338
=> FrameManager.GetDeviceRequestPromptManager(Client);
339+
340+
// See https://chromedevtools.github.io/devtools-protocol/tot/Page/#type-ReferrerPolicy.
341+
private static string ReferrerPolicyToProtocol(string referrerPolicy)
342+
{
343+
// Transform kebab-case to camelCase
344+
return string.IsNullOrEmpty(referrerPolicy) ? null :
345+
Regex.Replace(referrerPolicy, "-(.)", match => match.Groups[1].Value.ToUpperInvariant());
346+
}
338347
}

0 commit comments

Comments
 (0)