From 0469abd4a9c9270a1fdc962969e36e63699af8b4 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 10 Dec 2017 21:51:33 +0100 Subject: upgrade dependencies --- node_modules/remove-trailing-separator/index.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'node_modules/remove-trailing-separator/index.js') diff --git a/node_modules/remove-trailing-separator/index.js b/node_modules/remove-trailing-separator/index.js index 9f0de5334..512306b88 100644 --- a/node_modules/remove-trailing-separator/index.js +++ b/node_modules/remove-trailing-separator/index.js @@ -1,13 +1,17 @@ var isWin = process.platform === 'win32'; module.exports = function (str) { - while (endsInSeparator(str)) { - str = str.slice(0, -1); + var i = str.length - 1; + if (i < 2) { + return str; } - return str; + while (isSeparator(str, i)) { + i--; + } + return str.substr(0, i + 1); }; -function endsInSeparator(str) { - var last = str[str.length - 1]; - return str.length > 1 && (last === '/' || (isWin && last === '\\')); +function isSeparator(str, i) { + var char = str[i]; + return i > 0 && (char === '/' || (isWin && char === '\\')); } -- cgit v1.2.3