mirror of https://github.com/keeweb/keeweb.git
fix list dropbox
This commit is contained in:
parent
4891dbfb3d
commit
341b963608
|
@ -3,7 +3,7 @@
|
|||
var StorageBase = require('./storage-base'),
|
||||
DropboxLink = require('../comp/dropbox-link'),
|
||||
Locale = require('../util/locale'),
|
||||
UrlUtils = require('../util/url-util');
|
||||
UrlUtil = require('../util/url-util');
|
||||
|
||||
var StorageDropbox = StorageBase.extend({
|
||||
name: 'dropbox',
|
||||
|
@ -27,7 +27,7 @@ var StorageDropbox = StorageBase.extend({
|
|||
_toFullPath: function(path) {
|
||||
var rootFolder = this.appSettings.get('dropboxFolder');
|
||||
if (rootFolder) {
|
||||
path = UrlUtils.fixSlashes('/' + rootFolder + '/' + path);
|
||||
path = UrlUtil.fixSlashes('/' + rootFolder + '/' + path);
|
||||
}
|
||||
return path;
|
||||
},
|
||||
|
@ -41,7 +41,7 @@ var StorageDropbox = StorageBase.extend({
|
|||
} else if (ix === 1) {
|
||||
path = path.substr(rootFolder.length + 1);
|
||||
}
|
||||
path = UrlUtils.fixSlashes('/' + path);
|
||||
path = UrlUtil.fixSlashes('/' + path);
|
||||
}
|
||||
return path;
|
||||
},
|
||||
|
@ -197,7 +197,9 @@ var StorageDropbox = StorageBase.extend({
|
|||
DropboxLink.list(that._toFullPath(''), function(err, files, dirStat, filesStat) {
|
||||
if (err) { return callback(err); }
|
||||
var fileList = filesStat
|
||||
.filter(function(f) { return !f.isFolder && !f.isRemoved; })
|
||||
.filter(function(f) {
|
||||
return !f.isFolder && !f.isRemoved && UrlUtil.isKdbx(f.name);
|
||||
})
|
||||
.map(function(f) {
|
||||
return {
|
||||
name: f.name,
|
||||
|
@ -206,7 +208,7 @@ var StorageDropbox = StorageBase.extend({
|
|||
};
|
||||
});
|
||||
var dir = dirStat.inAppFolder ? Locale.openAppFolder :
|
||||
(UrlUtils.trimStartSlash(dirStat.path) || Locale.openRootFolder);
|
||||
(UrlUtil.trimStartSlash(dirStat.path) || Locale.openRootFolder);
|
||||
callback(null, fileList, dir);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var StorageBase = require('./storage-base');
|
||||
var StorageBase = require('./storage-base'),
|
||||
UrlUtil = require('../util/url-util');
|
||||
|
||||
var OneDriveClientId = {
|
||||
Production: '000000004818ED3A',
|
||||
|
@ -157,7 +158,7 @@ var StorageOneDrive = StorageBase.extend({
|
|||
}
|
||||
that.logger.debug('Listed', that.logger.ts(ts));
|
||||
var fileList = response.value
|
||||
.filter(function(f) { return f.name && /\.kdbx$/i.test(f.name); })
|
||||
.filter(function(f) { return f.name && UrlUtil.isKdbx(f.name); })
|
||||
.map(function(f) {
|
||||
return {
|
||||
name: f.name,
|
||||
|
|
|
@ -4,6 +4,7 @@ var UrlUtil = {
|
|||
multiSlashRegex: /\/{2,}/g,
|
||||
lastPartRegex: /[^\/]+$/,
|
||||
trimStartSlashRegex: /^\\/,
|
||||
kdbxEndRegex: /\.kdbx$/i,
|
||||
|
||||
getDataFileName: function(url) {
|
||||
var ix = url.lastIndexOf('/');
|
||||
|
@ -14,6 +15,10 @@ var UrlUtil = {
|
|||
return url;
|
||||
},
|
||||
|
||||
isKdbx: function(url) {
|
||||
return url && this.kdbxEndRegex.test(url);
|
||||
},
|
||||
|
||||
fixSlashes: function(url) {
|
||||
return url.replace(this.multiSlashRegex, '/');
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue