Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrundritt committed Aug 8, 2024
1 parent b9c138d commit 7967e0d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion HybridWebView/PathUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static string NormalizePath(string filename) =>
.Replace('\\', Path.DirectorySeparatorChar)
.Replace('/', Path.DirectorySeparatorChar);

public static void GetRelativePathAndContentType(Uri appOriginUri, Uri requestUri, string originalUrl, string? mainFileName, out string? relativePath, out string contentType, out string fullUrl)
public static void GetRelativePathAndContentType(Uri appOriginUri, Uri requestUri, string originalUrl, string? mainFileName, out string relativePath, out string contentType, out string fullUrl)
{
relativePath = appOriginUri.MakeRelativeUri(requestUri).ToString().Replace('/', '\\');
fullUrl = originalUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public AndroidHybridWebViewClient(HybridWebViewHandler handler) : base(handler)

if (!string.IsNullOrEmpty(originalUrl) && new Uri(requestUri) is Uri uri && HybridWebView.AppOriginUri.IsBaseOf(uri))
{
PathUtils.GetRelativePathAndContentType(HybridWebView.AppOriginUri, uri, originalUrl, webView.MainFile, out string? relativePath, out string contentType, out string fullUrl);
PathUtils.GetRelativePathAndContentType(HybridWebView.AppOriginUri, uri, originalUrl, webView.MainFile, out string relativePath, out string contentType, out string fullUrl);

Stream? contentStream = null;
IDictionary<string, string>? customHeaders = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public async void StartUrlSchemeTask(WKWebView webView, IWKUrlSchemeTask urlSche
if (!string.IsNullOrEmpty(originalUrl) && new Uri(url) is Uri uri && HybridWebView.AppOriginUri.IsBaseOf(uri))
{
var hwv = (HybridWebView)_webViewHandler.VirtualView;
PathUtils.GetRelativePathAndContentType(HybridWebView.AppOriginUri, uri, originalUrl, hwv.MainFile, out string? relativePath, out string contentType, out string fullUrl);
PathUtils.GetRelativePathAndContentType(HybridWebView.AppOriginUri, uri, originalUrl, hwv.MainFile, out string relativePath, out string contentType, out string fullUrl);

Stream? contentStream = null;
IDictionary<string, string>? customHeaders = null;
Expand Down Expand Up @@ -153,8 +153,8 @@ public async void StartUrlSchemeTask(WKWebView webView, IWKUrlSchemeTask urlSche
return (ms.ToArray(), contentType, StatusCode: 200, CustomHeaders: customHeaders);
}

var bundleRootDir = Path.Combine(NSBundle.MainBundle.ResourcePath, hwv.HybridAssetRoot!);
var assetPath = Path.Combine(bundleRootDir, relativePath);
string bundleRootDir = Path.Combine(NSBundle.MainBundle.ResourcePath, hwv.HybridAssetRoot ?? "");
string assetPath = Path.Combine(bundleRootDir, relativePath);

if (File.Exists(assetPath))
{
Expand Down
2 changes: 1 addition & 1 deletion HybridWebView/Platforms/Windows/HybridWebView.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private async void CoreWebView2_WebResourceRequested(CoreWebView2 sender, CoreWe

if (new Uri(requestUri) is Uri uri && AppOriginUri.IsBaseOf(uri))
{
PathUtils.GetRelativePathAndContentType(HybridWebView.AppOriginUri, uri, eventArgs.Request.Uri, MainFile, out string? relativePath, out string contentType, out string fullUrl);
PathUtils.GetRelativePathAndContentType(HybridWebView.AppOriginUri, uri, eventArgs.Request.Uri, MainFile, out string relativePath, out string contentType, out string fullUrl);

Stream? contentStream = null;
IDictionary<string, string>? customHeaders = null;
Expand Down
6 changes: 3 additions & 3 deletions HybridWebView/Platforms/iOS/HybridWebViewHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public async void StartUrlSchemeTask(WKWebView webView, IWKUrlSchemeTask urlSche
if (!string.IsNullOrEmpty(originalUrl) && new Uri(url) is Uri uri && HybridWebView.AppOriginUri.IsBaseOf(uri))
{
var hwv = (HybridWebView)_webViewHandler.VirtualView;
PathUtils.GetRelativePathAndContentType(HybridWebView.AppOriginUri, uri, originalUrl, hwv.MainFile, out string? relativePath, out string contentType, out string fullUrl);
PathUtils.GetRelativePathAndContentType(HybridWebView.AppOriginUri, uri, originalUrl, hwv.MainFile, out string relativePath, out string contentType, out string fullUrl);

Stream? contentStream = null;
IDictionary<string, string>? customHeaders = null;
Expand Down Expand Up @@ -155,8 +155,8 @@ public async void StartUrlSchemeTask(WKWebView webView, IWKUrlSchemeTask urlSche
return (ms.ToArray(), contentType, StatusCode: 200, CustomHeaders: customHeaders);
}

var bundleRootDir = Path.Combine(NSBundle.MainBundle.ResourcePath, hwv.HybridAssetRoot!);
var assetPath = Path.Combine(bundleRootDir, relativePath);
string bundleRootDir = Path.Combine(NSBundle.MainBundle.ResourcePath, hwv.HybridAssetRoot ?? "");
string assetPath = Path.Combine(bundleRootDir, relativePath);

if (File.Exists(assetPath))
{
Expand Down

0 comments on commit 7967e0d

Please sign in to comment.