Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Fixed util methods for windows paths

Borislav Sapundzhiev121fd63de9ac
diff --git a/data/js/utils.js b/data/js/utils.js
index 3cfdc4d13..930da69fd 100644
--- a/data/js/utils.js
+++ b/data/js/utils.js
@@ -4,6 +4,7 @@
/* global define */
define(function(require, exports, module) {
'use strict';
+ var TSCORE = require('tscore');
console.log('Loading utils.js ...');
//Conversion utility
@@ -50,13 +51,12 @@ define(function(require, exports, module) {
};
var baseName = function(dirPath) {
- var fileName = dirPath.substring(dirPath.lastIndexOf("/") + 1, dirPath.length);
+ var fileName = dirPath.substring(dirPath.lastIndexOf(TSCORE.dirSeparator) + 1, dirPath.length);
return fileName ? fileName : dirPath;
};
var dirName = function(dirPath) {
- return dirPath.replace(/\/[^\/]*$/, '');
- //return dirPath.match( /(.*)[/\]/)[1];
+ return dirPath.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
};
var getFileExt = function(fileURL) {