| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | /*! |
| 2 | * normalize-path <https://github.com/jonschlinkert/normalize-path> |
| 3 | * |
| 4 | * Copyright (c) 2014-2017, Jon Schlinkert. |
| 5 | * Released under the MIT License. |
| 6 | */ |
| 7 | |
| 8 | var removeTrailingSeparator = require('remove-trailing-separator'); |
| 9 | |
| 10 | module.exports = function normalizePath(str, stripTrailing) { |
| 11 | if (typeof str !== 'string') { |
| 12 | throw new TypeError('expected a string'); |
| 13 | } |
| 14 | str = str.replace(/[\\\/]+/g, '/'); |
| 15 | if (stripTrailing !== false) { |
| 16 | str = removeTrailingSeparator(str); |
| 17 | } |
| 18 | return str; |
| 19 | }; |