nice-path 3.2.1 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -120,18 +120,22 @@ class Path {
|
|
|
120
120
|
// we clone this cause we're gonna mutate it
|
|
121
121
|
const segments = [...this.segments];
|
|
122
122
|
const newSegments = [];
|
|
123
|
+
function isNewSegmentsEmptyExcludingDots() {
|
|
124
|
+
return (newSegments.filter((segment) => segment !== "." && segment !== "..")
|
|
125
|
+
.length === 0);
|
|
126
|
+
}
|
|
123
127
|
let currentSegment;
|
|
124
128
|
while (segments.length > 0) {
|
|
125
129
|
currentSegment = segments.shift();
|
|
126
130
|
switch (currentSegment) {
|
|
127
131
|
case ".": {
|
|
128
|
-
if (
|
|
132
|
+
if (isNewSegmentsEmptyExcludingDots()) {
|
|
129
133
|
newSegments.push(currentSegment);
|
|
130
134
|
}
|
|
131
135
|
break;
|
|
132
136
|
}
|
|
133
137
|
case "..": {
|
|
134
|
-
if (
|
|
138
|
+
if (isNewSegmentsEmptyExcludingDots()) {
|
|
135
139
|
newSegments.push(currentSegment);
|
|
136
140
|
}
|
|
137
141
|
else {
|