source: trip-planner-front/node_modules/remove-trailing-separator/index.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 322 bytes
RevLine 
[6a3a178]1var isWin = process.platform === 'win32';
2
3module.exports = function (str) {
4 var i = str.length - 1;
5 if (i < 2) {
6 return str;
7 }
8 while (isSeparator(str, i)) {
9 i--;
10 }
11 return str.substr(0, i + 1);
12};
13
14function isSeparator(str, i) {
15 var char = str[i];
16 return i > 0 && (char === '/' || (isWin && char === '\\'));
17}
Note: See TracBrowser for help on using the repository browser.