backoffice/node_modules/remove-trailing-separator/index.js

14 lines
292 B
JavaScript
Raw Normal View History

2020-02-06 10:09:39 +00:00
var isWin = process.platform === 'win32';
module.exports = function (str) {
while (endsInSeparator(str)) {
str = str.slice(0, -1);
}
return str;
};
function endsInSeparator(str) {
var last = str[str.length - 1];
return str.length > 1 && (last === '/' || (isWin && last === '\\'));
}