From dcad754d1d107275a2680e57b67f1dd7be1ba2d9 Mon Sep 17 00:00:00 2001 From: Israel Merljak Date: Tue, 26 Feb 2019 07:45:17 -0300 Subject: [PATCH] fix(ios-webview): loading of local-file dependency (#6947) Fixes loading of html dependencies when loading a local file to web view. I've just implemented the code changes in the patch provided by @gregorywojcik [here](https://github.com/NativeScript/NativeScript/issues/6377#issuecomment-433322681) references #6377 --- tns-core-modules/ui/web-view/web-view.ios.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tns-core-modules/ui/web-view/web-view.ios.ts b/tns-core-modules/ui/web-view/web-view.ios.ts index 67425f475..b350905a9 100644 --- a/tns-core-modules/ui/web-view/web-view.ios.ts +++ b/tns-core-modules/ui/web-view/web-view.ios.ts @@ -131,7 +131,8 @@ export class WebView extends WebViewBase { public _loadUrl(src: string) { if (src.startsWith("file:///")) { - this.ios.loadFileURLAllowingReadAccessToURL(NSURL.URLWithString(src), NSURL.URLWithString(src)); + var cachePath = src.substring(0, src.lastIndexOf("/")); + this.ios.loadFileURLAllowingReadAccessToURL(NSURL.URLWithString(src), NSURL.URLWithString(cachePath)); } else { this.ios.loadRequest(NSURLRequest.requestWithURL(NSURL.URLWithString(src))); } @@ -160,4 +161,4 @@ export class WebView extends WebViewBase { public reload() { this.ios.reload(); } -} \ No newline at end of file +}