Skip to content
Permalink
Browse files
CB-11848 windows: Remove duplicate slash after file system path
 This closes #195, this closes #112
  • Loading branch information
matrosov-nikita authored and vladimir-kotikov committed Oct 6, 2016
1 parent 7dbef06 commit 7ae74f5385e14b1e81ed7396ba12c21782d6eac7
Showing 2 changed files with 21 additions and 2 deletions.
@@ -154,8 +154,13 @@ var WinFS = function(name, root) {
if (this.winpath && !/\/$/.test(this.winpath)) {
this.winpath += "/";
}
this.makeNativeURL = function(path) {
return FileSystem.encodeURIPath(this.root.nativeURL + sanitize(path.replace(':','%3A')));};
this.makeNativeURL = function (path) {
//CB-11848: This RE supposed to match all leading slashes in sanitized path.
//Removing leading slash to avoid duplicating because this.root.nativeURL already has trailing slash
var regLeadingSlashes = /^\/*/;
var sanitizedPath = sanitize(path.replace(':', '%3A')).replace(regLeadingSlashes, '');
return FileSystem.encodeURIPath(this.root.nativeURL + sanitizedPath);
};
root.fullPath = '/';
if (!root.nativeURL)
root.nativeURL = 'file://'+sanitize(this.winpath + root.fullPath).replace(':','%3A');
@@ -368,6 +368,20 @@ exports.defineAutoTests = function () {
}
createDirectory(fileName, gotDirectory, failed.bind(null, done, 'createDirectory - Error creating directory: ' + fileName), failed.bind(null, done, 'createDirectory - Error creating directory: ' + fileName));
});

it("file.spec.9.7 should resolve a file with valid nativeURL", function (done) {
var fileName = "de.create.file",
win = function (entry) {
var path = entry.nativeURL.split('///')[1];
expect(/\/{2,}/.test(path)).toBeFalsy();
// cleanup
deleteEntry(entry.name, done);
};
root.getFile(fileName, {
create: true
}, win, succeed.bind(null, done, 'root.getFile - Error unexpected callback, file should not exists: ' + fileName));
});

it("file.spec.10 resolve valid file name with parameters", function (done) {
var fileName = "resolve.file.uri.params",
win = function (fileEntry) {

0 comments on commit 7ae74f5

Please sign in to comment.