normalizeURL file:///var.. -> http://localhost:8080/var


Hello, I used WKWebView (

import { normalizeURL } from 'ionic-angular';

let path = cordova.file.dataDirectory;
console.log('Original: ' + path);

path = normalizeURL(path);
console.log('Fixed: ' + path);

and have result, not like described in manual:


converted to


but as i understand, should be


1 Like

Sorry for probably silly question, any way to ensure if WKWebView used to render views ?

I had couple vierd bugs related to update to WKWebView, and strange, file:/// still works good.


I am seeing the same thing on iOS. Normalized URL starts with http://localhost:8080 which is then causing me problems later in my code.


And again to this issue.
Example from documentation:

let aaa = "file:///usr/home/dev/app/index.html";
aaa = normalizeURL(aaa);

results “file:///usr/home/dev/app/index.html”

somewhy file:// prefix not removes

and IOS works with file://


I am also working with WKWebview, and experiencing the same issue (even if I am removing file:// manually).
Did you find a solution?

There might be something possible with DomSanitizer or cordova-plugin-file.

FYI, you can test if you are running WkWebView with the following code:

// iOS - WKWebView
if ('ios')) {
  if (window.indexedDB) {
    console.log('[SystemService]', 'iOS', 'WKWebView');
  } else {
    console.log('[SystemService]', 'iOS', 'UIWebView');

I also tried to add/configure Content-Security-Policy (<meta> in the index.html) & add/configure cordova-plugin-whitelist (<allow-xxx ...> in the config.xml) without any success.


Any solution found for this issue?


You could write your own function in a utils folder:

let toNormalize = "file:///var/mobile/Containers/Data/Application/18438A3A-9ABD-440F-9989-0C009A6CCC8C/Library/NoCloud/"

return toNormalize.split("//", 1)[1]

When you changed the path were you able to get the picture or file? I used the normailzeURL like you did and got the same results. I ended up just sub-stringing it to get what I wanted, but I still get an error when accessing files or pictures… domain=pluginkit code=13 query cancelled userinfo= nslocalizeddescription=query cancelled


I’ve the same problem from the last update of plugin webview
<plugin name="cordova-plugin-ionic-webview" spec="^3.1.1">

normalizeUrl() was replaced by convertFileSrc(). It works well on android real device but fails on iOS for me.
So i’m still stucked (i’m using file plugin to read a local video without issue but when i’m trying to display this video “sanitized” link in a videogular or html5 element, it fails on iOS.

let win: any = window; // hack compilator
let safeURL = win.Ionic.WebView.convertFileSrc('file:///myFile/....');

@lucbonnin I have the same problem using these convertFileSrc URLs and even after adding
ionic: to the index.html content-security-policy meta tag, videos with a src like below will still not play:



As a work around, i’ve added
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />

to the config.xml (only for platform iOS). It is a bit ugly i know but i had no other choice except downgrading to webview 1.x and that was ugliest.

I hope @ionic_team will be able to fix this iOS issue soon.

1 Like