|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 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 | } // ensure that win32 namespaces has two leading slashes, so that the path is
|
|---|
| 18 | // handled properly by the win32 version of path.parse() after being normalized
|
|---|
| 19 | // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | let prefix = '';
|
|---|
| 23 |
|
|---|
| 24 | if (len > 4 && path[3] === '\\') {
|
|---|
| 25 | // eslint-disable-next-line prefer-destructuring
|
|---|
| 26 | const ch = path[2];
|
|---|
| 27 |
|
|---|
| 28 | if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') {
|
|---|
| 29 | // eslint-disable-next-line no-param-reassign
|
|---|
| 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 | } // eslint-disable-next-line import/prefer-default-export |
|---|
Note:
See
TracBrowser
for help on using the repository browser.