1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.normalizePath = normalizePath;
|
7 |
|
8 | function normalizePath(path, stripTrailing) {
|
9 | if (path === '\\' || path === '/') {
|
10 | return '/';
|
11 | }
|
12 |
|
13 | const len = path.length;
|
14 |
|
15 | if (len <= 1) {
|
16 | return path;
|
17 | }
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | let prefix = '';
|
23 |
|
24 | if (len > 4 && path[3] === '\\') {
|
25 |
|
26 | const ch = path[2];
|
27 |
|
28 | if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') {
|
29 |
|
30 | path = path.slice(2);
|
31 | prefix = '//';
|
32 | }
|
33 | }
|
34 |
|
35 | const segs = path.split(/[/\\]+/);
|
36 |
|
37 | if (stripTrailing !== false && segs[segs.length - 1] === '') {
|
38 | segs.pop();
|
39 | }
|
40 |
|
41 | return prefix + segs.join('/');
|
42 | } |
\ | No newline at end of file |