Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Local images not accessible from WKWebView #198

Closed
1 task done
brunnobraga opened this issue Jan 23, 2020 · 2 comments · Fixed by #200
Closed
1 task done

[Feature] Local images not accessible from WKWebView #198

brunnobraga opened this issue Jan 23, 2020 · 2 comments · Fixed by #200

Comments

@brunnobraga
Copy link
Contributor

Please help prevent duplicate issues before submitting a new one:

Report

What did you do?

I'm using DownView(frame: .zero, markdownString: markdown, templateBundle: bundle) and in this case bundle points to a folder in my app's documents directory. The markdown files and associated images are downloaded to this location during runtime, could be refreshed and must be kept for offline use (the template assets might be dynamic in the future too, but its not at the moment).

What did you expect to happen?

DownView renders using the template and following referenced style, JS and images.

What happened instead?

It renders the content of template file with inserted markdown content, but any content linked on index.html with local references does not load (eg. css, js, images).

Using Safari's web inspector to check on WKWebView I can see this on console:
Failed to load resource: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 1.)
Which after some research I found to be a permission issue.

I searched deeper and I think this traces down to use of loadHTMLString(_:baseURL:). baseURL points to the correct place, but in this case WKWebView doesn't have access to it by default. The alternative would be to use loadFileURL(_:allowingReadAccessTo:) which can provide read access to a path.

I wasn't sure if I should file this under feature request or a bug.

@iwasrobbed-ks
Copy link
Collaborator

Feel free to open a pull request as long as it's backwards compatible with the existing API

@brunnobga
Copy link
Contributor

Created #200 for this.

@iwasrobbed iwasrobbed changed the title Local images not accessible from WKWebView [Feature] Local images not accessible from WKWebView Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants