wallet-core/node_modules/remove-trailing-separator/index.js

18 lines
322 B
JavaScript
Raw Normal View History

2017-08-14 05:01:11 +02:00
var isWin = process.platform === 'win32';
2016-10-10 03:43:44 +02:00
module.exports = function (str) {
2017-12-10 21:51:33 +01:00
var i = str.length - 1;
if (i < 2) {
return str;
2016-10-10 03:43:44 +02:00
}
2017-12-10 21:51:33 +01:00
while (isSeparator(str, i)) {
i--;
}
return str.substr(0, i + 1);
2016-10-10 03:43:44 +02:00
};
2017-12-10 21:51:33 +01:00
function isSeparator(str, i) {
var char = str[i];
return i > 0 && (char === '/' || (isWin && char === '\\'));
2016-10-10 03:43:44 +02:00
}