cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an-s...@apache.org
Subject cordova-plugin-file git commit: CB-11848 windows: Remove duplicate slash after file system path
Date Thu, 06 Oct 2016 14:21:48 GMT
Repository: cordova-plugin-file
Updated Branches:
  refs/heads/master 7dbef06f6 -> 7ae74f538


CB-11848 windows: Remove duplicate slash after file system path

 This closes #195, this closes #112


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/7ae74f53
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/7ae74f53
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/7ae74f53

Branch: refs/heads/master
Commit: 7ae74f5385e14b1e81ed7396ba12c21782d6eac7
Parents: 7dbef06
Author: Nikita Matrosov <matrosov.nikita94@gmail.com>
Authored: Thu Sep 29 15:36:29 2016 +0300
Committer: Vladimir Kotikov <kotikov.vladimir@gmail.com>
Committed: Thu Oct 6 17:20:25 2016 +0300

----------------------------------------------------------------------
 src/windows/FileProxy.js |  9 +++++++--
 tests/tests.js           | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/7ae74f53/src/windows/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/FileProxy.js b/src/windows/FileProxy.js
index 79a7f41..c342a56 100644
--- a/src/windows/FileProxy.js
+++ b/src/windows/FileProxy.js
@@ -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');

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/7ae74f53/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index c57d18b..eb74c14 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -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) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message