index.js 429 B

123456789101112131415161718
  1. /*!
  2. * normalize-path <https://github.com/jonschlinkert/normalize-path>
  3. *
  4. * Copyright (c) 2014-2015, Jon Schlinkert.
  5. * Licensed under the MIT License
  6. */
  7. module.exports = function normalizePath(str, stripTrailing) {
  8. if (typeof str !== 'string') {
  9. throw new TypeError('expected a string');
  10. }
  11. str = str.replace(/[\\\/]+/g, '/');
  12. if (stripTrailing !== false) {
  13. str = str.replace(/\/$/, '');
  14. }
  15. return str;
  16. };