Skip to content

Commit db16dc2

Browse files
eduardoRothihadeed
authored andcommitted
fix(wkwebview): images not loading in Ionic WKWebView (#160)
1 parent 4f65317 commit db16dc2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/providers/image-loader.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { DirectoryEntry, File, FileEntry, FileError } from '@ionic-native/file';
33
import { HttpClient } from '@angular/common/http';
4+
import { normalizeUrl } from 'ionic-angular';
45
import { ImageLoaderConfig } from "./image-loader-config";
56
import { Platform } from 'ionic-angular';
67
import { Observable } from 'rxjs/Observable';
@@ -452,8 +453,8 @@ export class ImageLoader {
452453
// therefore the file needs to be copied into that directory first!
453454
if (this.isIonicWKWebView) {
454455

455-
// Ionic WKWebView can access all files, but we just need to replace file:/// with http://localhost:8080/
456-
resolve(fileEntry.nativeURL.replace('file:///', 'http://localhost:8080/'));
456+
// Use Ionic normalizeUrl to generate the right URL for Ionic WKWebView
457+
resolve(normalizeUrl(fileEntry.nativeURL));
457458

458459
} else if (this.isWKWebView) {
459460

0 commit comments

Comments
 (0)