Skip to content

Commit

Permalink
bugfix android and angular-q
Browse files Browse the repository at this point in the history
  • Loading branch information
markmarijnissen committed Nov 20, 2014
1 parent 8f8626e commit 7e6e87c
Show file tree
Hide file tree
Showing 11 changed files with 25,690 additions and 21 deletions.
13 changes: 9 additions & 4 deletions dist/CordovaAppLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ var CordovaAppLoader =
window.ProgressEvent = function ProgressEvent(){}
}

function removeFirstSlash(path){
if(path[0] === '/') path = path.substr(1);
return path;
}

/* Cordova File Cache x */
function FileCache(options){
// cordova-promise-fs
Expand All @@ -229,9 +234,8 @@ var CordovaAppLoader =
this._cacheBuster = !!options.cacheBuster;

// normalize path
this._localRoot = options.localRoot || 'data';
this._localRoot = removeFirstSlash(options.localRoot || 'data');
if(this._localRoot[this._localRoot.length -1] !== '/') this._localRoot += '/';
if(this._localRoot[0] === '/') this._localRoot = this._localRoot.substr(1);

this._serverRoot = options.serverRoot || '';
if(!!this._serverRoot && this._serverRoot[this._serverRoot.length-1] !== '/') this._serverRoot += '/';
Expand All @@ -256,7 +260,8 @@ var CordovaAppLoader =
self._fs.list(self._localRoot,'rfe').then(function(entries){
self._cached = {};
entries = entries.map(function(entry){
self._cached[entry.fullPath] = {
var fullPath = removeFirstSlash(entry.fullPath);
self._cached[fullPath] = {
toInternalURL: isCordova? entry.toInternalURL(): entry.toURL(),
toURL: entry.toURL(),
};
Expand Down Expand Up @@ -446,7 +451,7 @@ var CordovaAppLoader =
url = url || '';
len = this._serverRoot.length;
if(url.substr(0,len) !== this._serverRoot) {
if(url[0] === '/') url = url.substr(1);
url = removeFirstSlash(url);
return this._localRoot + url;
} else {
return this._localRoot + url.substr(len);
Expand Down
2 changes: 1 addition & 1 deletion dist/CordovaAppLoader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions dist/CordovaPromiseFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var CordovaPromiseFS =
});
} else {
/* FileTransfer implementation for Chrome */
deviceready = Promise.resolve();
deviceready = ResolvedPromise(true);
if(typeof webkitRequestFileSystem !== 'undefined'){
window.requestFileSystem = webkitRequestFileSystem;
window.FileTransfer = function FileTransfer(){};
Expand All @@ -129,6 +129,13 @@ var CordovaPromiseFS =
}
}

/* Promise resolve helper */
function ResolvedPromise(value){
return new Promise(function(resolve){
return resolve(value);
});
}

/* the filesystem! */
var fs = new Promise(function(resolve,reject){
deviceready.then(function(){
Expand Down Expand Up @@ -351,7 +358,7 @@ var CordovaPromiseFS =
return dir(path).then(function(dirEntry){
var dirReader = dirEntry.createReader();
dirReader.readEntries(function(entries) {
var promises = [Promise.resolve(entries)];
var promises = [ResolvedPromise(entries)];
if(recursive) {
entries
.filter(function(entry){return entry.isDirectory; })
Expand Down

0 comments on commit 7e6e87c

Please sign in to comment.