Skip to content

Commit a321589

Browse files
authored
Add option to disable the loopback check (#57)
1 parent aa7a1d0 commit a321589

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/SharpWebview/SharpWebview.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Owners>Gerrit 'Geaz' Gazic</Owners>
99
<Description>C# bindings for zserge/webview - Batteries included</Description>
1010
<PackageId>SharpWebview</PackageId>
11-
<PackageVersion>0.12.0</PackageVersion>
11+
<PackageVersion>0.12.1</PackageVersion>
1212
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1313
<PackageProjectUrl>https://github.com/webview/webview_csharp</PackageProjectUrl>
1414
</PropertyGroup>

src/SharpWebview/Webview.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class Webview : IDisposable
1414
{
1515
private bool _disposed = false;
1616
private bool? _loopbackEnabled = null;
17+
private bool _skipLoopbackCheck = false;
1718
private List<CallBackFunction> callbacks = new List<CallBackFunction>();
1819
private List<DispatchFunction> dispatchFunctions = new List<DispatchFunction>();
1920

@@ -29,13 +30,17 @@ public class Webview : IDisposable
2930
/// <param name="interceptExternalLinks">
3031
/// Set to true, top open external links in system browser.
3132
/// </param>
32-
public Webview(bool debug = false, bool interceptExternalLinks = false)
33+
/// <param name="skipLoopbackCheck">
34+
/// Set to true to skip checking for the loopback exception.
35+
/// </param>
36+
public Webview(bool debug = false, bool interceptExternalLinks = false, bool skipLoopbackCheck = false)
3337
{
3438
_nativeWebview = Bindings.webview_create(debug ? 1 : 0, IntPtr.Zero);
3539
if(interceptExternalLinks)
3640
{
3741
InterceptExternalLinks();
3842
}
43+
_skipLoopbackCheck = skipLoopbackCheck;
3944
}
4045

4146
/// <summary>
@@ -279,8 +284,10 @@ private string ExtractUrlArgument(string jsonArray)
279284

280285
private bool? CheckLoopbackException(string url)
281286
{
287+
if (_skipLoopbackCheck)
288+
return true;
282289
// https://docs.microsoft.com/de-de/windows/win32/sysinfo/operating-system-version
283-
if(Environment.OSVersion.Version.Major < 6 || (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor < 2))
290+
else if(Environment.OSVersion.Version.Major < 6 || (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor < 2))
284291
return true;
285292
else if(!url.Contains("localhost") && !url.Contains("127.0.0.1"))
286293
return null;

0 commit comments

Comments
 (0)