in www/browser/Preparing.js [61:107]
window.resolveLocalFileSystemURL = function (url, win, fail) {
/* If url starts with `cdvfile` then we need convert it to Chrome real url first:
cdvfile://localhost/persistent/path/to/file -> filesystem:file://persistent/path/to/file */
if (url.trim().substr(0, 7) === 'cdvfile') {
/* Quirk:
Plugin supports cdvfile://localhost (local resources) only.
I.e. external resources are not supported via cdvfile. */
if (url.indexOf('cdvfile://localhost') !== -1) {
// Browser supports temporary and persistent only
const indexPersistent = url.indexOf('persistent');
const indexTemporary = url.indexOf('temporary');
/* Chrome urls start with 'filesystem:' prefix. See quirk:
toURL function in Chrome returns filesystem:-prefixed path depending on application host.
For example, filesystem:file:///persistent/somefile.txt,
filesystem:http://localhost:8080/persistent/somefile.txt. */
let prefix = 'filesystem:file:///';
if (location.protocol !== 'file:') {
prefix = 'filesystem:' + location.origin + '/';
}
let result;
if (indexPersistent !== -1) {
// cdvfile://localhost/persistent/path/to/file -> filesystem:file://persistent/path/to/file
// or filesystem:http://localhost:8080/persistent/path/to/file
result = prefix + 'persistent' + url.substr(indexPersistent + 10);
nativeResolveLocalFileSystemURL(result, win, fail);
return;
}
if (indexTemporary !== -1) {
// cdvfile://localhost/temporary/path/to/file -> filesystem:file://temporary/path/to/file
// or filesystem:http://localhost:8080/temporary/path/to/file
result = prefix + 'temporary' + url.substr(indexTemporary + 9);
nativeResolveLocalFileSystemURL(result, win, fail);
return;
}
}
// cdvfile other than local file resource is not supported
if (fail) {
fail(new FileError(FileError.ENCODING_ERR));
}
} else {
nativeResolveLocalFileSystemURL(url, win, fail);
}
};