blob: 4a4f8ccdb12c3aae161054b47fade298aa8ab5e5 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001/*!
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
8var removeTrailingSeparator = require('remove-trailing-separator');
9
10module.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};