123456789101112131415161718192021222324252627282930313233343536373839404142 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.normalizePath = normalizePath;
- function normalizePath(path, stripTrailing) {
- if (path === '\\' || path === '/') {
- return '/';
- }
- const len = path.length;
- if (len <= 1) {
- return path;
- }
-
-
- let prefix = '';
- if (len > 4 && path[3] === '\\') {
-
- const ch = path[2];
- if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') {
-
- path = path.slice(2);
- prefix = '//';
- }
- }
- const segs = path.split(/[/\\]+/);
- if (stripTrailing !== false && segs[segs.length - 1] === '') {
- segs.pop();
- }
- return prefix + segs.join('/');
- }
|