diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
commit | 0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch) | |
tree | f9864d4a4148621378958794cbbfdc2393733283 /node_modules/remove-trailing-separator/index.js | |
parent | 6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff) |
upgrade dependencies
Diffstat (limited to 'node_modules/remove-trailing-separator/index.js')
-rw-r--r-- | node_modules/remove-trailing-separator/index.js | 16 |
1 files changed, 10 insertions, 6 deletions
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 === '\\')); } |