nice-path 3.2.0 → 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.
Files changed (2) hide show
  1. package/dist/index.js +7 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -64,7 +64,7 @@ class Path {
64
64
  * starts with either `/`, `\`, or a drive letter (ie `C:`).
65
65
  */
66
66
  static isAbsolute(path) {
67
- if (this.constructor.isPath(path)) {
67
+ if (this.isPath(path)) {
68
68
  return path.isAbsolute();
69
69
  }
70
70
  else {
@@ -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 (newSegments.length === 0) {
132
+ if (isNewSegmentsEmptyExcludingDots()) {
129
133
  newSegments.push(currentSegment);
130
134
  }
131
135
  break;
132
136
  }
133
137
  case "..": {
134
- if (newSegments.length === 0) {
138
+ if (isNewSegmentsEmptyExcludingDots()) {
135
139
  newSegments.push(currentSegment);
136
140
  }
137
141
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-path",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {