Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

Commit

Permalink
MOBILE-526 contents: Encode custom directories
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Mar 19, 2015
1 parent 3eaba90 commit 1004dd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if (typeof(msg) === "string") {
var error = msg + "\n\nFile: " + url + "\nLine: " + lineNumber;
// Ommit cordova and 3rd party libs errors.
if (url.indexOf("cordova.js") == -1 && url.indexOf("externallib") == -1 &&
if (url.indexOf("cordova") == -1 && url.indexOf("externallib") == -1 &&
url.indexOf("org.apache.cordova") == -1) {
window.alert(error);
}
Expand Down
13 changes: 9 additions & 4 deletions lib/mm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2487,9 +2487,14 @@ var MM = {
}
);
} else if (MM.deviceOS == 'ios' && typeof handleDocumentWithURL == 'function') {
// The plugin needs the file name an path encoded.
var path = MM.util.getDirectoryAndFile(link);
var file = path.directory + '/' + encodeURIComponent(decodeURIComponent(path.file));

var fsRoot = MM.fs.getRoot();
// Encode/decode the specific file path, note that a path may contain directories with white spaces, special characters...
if (link.indexOf(fsRoot > -1)) {
link = link.replace(fsRoot, "");
link = encodeURIComponent(decodeURIComponent(link));
link = fsRoot + link;
}

handleDocumentWithURL(
function() {
Expand All @@ -2502,7 +2507,7 @@ var MM = {
}
MM._openFileWithBrowser(link);
},
file
link
);
} else {
// Last try, launch the file with the browser.
Expand Down

0 comments on commit 1004dd5

Please sign in to comment.