Socket
Socket
Sign inDemoInstall

@file-services/posix-path

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@file-services/posix-path - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

8

cjs/normalize.js

@@ -30,3 +30,3 @@ "use strict";

let dots = 0;
let code;
let code = 0;
for (let i = 0; i <= path.length; ++i) {

@@ -37,3 +37,2 @@ if (i < path.length) {

else if (code === constants_1.CHAR_FORWARD_SLASH) {
// isPosixPathSeparator
break;

@@ -45,7 +44,6 @@ }

if (code === constants_1.CHAR_FORWARD_SLASH) {
// isPosixPathSeparator
if (lastSlash === i - 1 || dots === 1) {
// NOOP
}
else if (lastSlash !== i - 1 && dots === 2) {
else if (dots === 2) {
if (res.length < 2 ||

@@ -69,3 +67,3 @@ lastSegmentLength !== 2 ||

}
else if (res.length === 2 || res.length === 1) {
else if (res.length !== 0) {
res = '';

@@ -72,0 +70,0 @@ lastSegmentLength = 0;

@@ -9,2 +9,3 @@ "use strict";

}
// Trim leading forward slashes.
from = resolve_1.resolve(from);

@@ -15,16 +16,7 @@ to = resolve_1.resolve(to);

}
// Trim any leading backslashes
let fromStart = 1;
while (fromStart < from.length && from.charCodeAt(fromStart) === constants_1.CHAR_FORWARD_SLASH) {
fromStart++;
}
const fromStart = 1;
const fromEnd = from.length;
const fromLen = fromEnd - fromStart;
// Trim any leading backslashes
let toStart = 1;
while (toStart < to.length && to.charCodeAt(toStart) === constants_1.CHAR_FORWARD_SLASH) {
toStart++;
}
const toEnd = to.length;
const toLen = toEnd - toStart;
const toStart = 1;
const toLen = to.length - toStart;
// Compare paths to find the longest common path from root

@@ -56,13 +48,6 @@ const length = fromLen < toLen ? fromLen : toLen;

}
else if (fromLen > length) {
if (from.charCodeAt(fromStart + i) === constants_1.CHAR_FORWARD_SLASH) {
// We get here if `to` is the exact base path for `from`.
// For example: from='/foo/bar/baz'; to='/foo/bar'
lastCommonSep = i;
}
else if (i === 0) {
// We get here if `to` is the root.
// For example: from='/foo'; to='/'
lastCommonSep = 0;
}
else if (fromLen > length && from.charCodeAt(fromStart + i) === constants_1.CHAR_FORWARD_SLASH) {
// We get here if `to` is the exact base path for `from`.
// For example: from='/foo/bar/baz'; to='/foo/bar'
lastCommonSep = i;
}

@@ -72,3 +57,3 @@ }

// Generate the relative path based on the path difference between `to`
// and `from`
// and `from`.
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {

@@ -79,14 +64,7 @@ if (i === fromEnd || from.charCodeAt(i) === constants_1.CHAR_FORWARD_SLASH) {

}
toStart += lastCommonSep;
// Lastly, append the rest of the destination (`to`) path that comes after
// the common path parts
if (out.length > 0) {
return `${out}${to.slice(toStart)}`;
}
if (to.charCodeAt(toStart) === constants_1.CHAR_FORWARD_SLASH) {
++toStart;
}
return to.slice(toStart);
// the common path parts.
return `${out}${to.slice(toStart + lastCommonSep)}`;
}
exports.relative = relative;
//# sourceMappingURL=relative.js.map

@@ -27,3 +27,3 @@ import { CHAR_FORWARD_SLASH, CHAR_DOT, sep } from './constants';

let dots = 0;
let code;
let code = 0;
for (let i = 0; i <= path.length; ++i) {

@@ -34,3 +34,2 @@ if (i < path.length) {

else if (code === CHAR_FORWARD_SLASH) {
// isPosixPathSeparator
break;

@@ -42,7 +41,6 @@ }

if (code === CHAR_FORWARD_SLASH) {
// isPosixPathSeparator
if (lastSlash === i - 1 || dots === 1) {
// NOOP
}
else if (lastSlash !== i - 1 && dots === 2) {
else if (dots === 2) {
if (res.length < 2 ||

@@ -66,3 +64,3 @@ lastSegmentLength !== 2 ||

}
else if (res.length === 2 || res.length === 1) {
else if (res.length !== 0) {
res = '';

@@ -69,0 +67,0 @@ lastSegmentLength = 0;

@@ -7,2 +7,3 @@ import { CHAR_FORWARD_SLASH } from './constants';

}
// Trim leading forward slashes.
from = resolve(from);

@@ -13,16 +14,7 @@ to = resolve(to);

}
// Trim any leading backslashes
let fromStart = 1;
while (fromStart < from.length && from.charCodeAt(fromStart) === CHAR_FORWARD_SLASH) {
fromStart++;
}
const fromStart = 1;
const fromEnd = from.length;
const fromLen = fromEnd - fromStart;
// Trim any leading backslashes
let toStart = 1;
while (toStart < to.length && to.charCodeAt(toStart) === CHAR_FORWARD_SLASH) {
toStart++;
}
const toEnd = to.length;
const toLen = toEnd - toStart;
const toStart = 1;
const toLen = to.length - toStart;
// Compare paths to find the longest common path from root

@@ -54,13 +46,6 @@ const length = fromLen < toLen ? fromLen : toLen;

}
else if (fromLen > length) {
if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
// We get here if `to` is the exact base path for `from`.
// For example: from='/foo/bar/baz'; to='/foo/bar'
lastCommonSep = i;
}
else if (i === 0) {
// We get here if `to` is the root.
// For example: from='/foo'; to='/'
lastCommonSep = 0;
}
else if (fromLen > length && from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
// We get here if `to` is the exact base path for `from`.
// For example: from='/foo/bar/baz'; to='/foo/bar'
lastCommonSep = i;
}

@@ -70,3 +55,3 @@ }

// Generate the relative path based on the path difference between `to`
// and `from`
// and `from`.
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {

@@ -77,13 +62,6 @@ if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {

}
toStart += lastCommonSep;
// Lastly, append the rest of the destination (`to`) path that comes after
// the common path parts
if (out.length > 0) {
return `${out}${to.slice(toStart)}`;
}
if (to.charCodeAt(toStart) === CHAR_FORWARD_SLASH) {
++toStart;
}
return to.slice(toStart);
// the common path parts.
return `${out}${to.slice(toStart + lastCommonSep)}`;
}
//# sourceMappingURL=relative.js.map
{
"name": "@file-services/posix-path",
"description": "Node's posix-`path` implementation converted to TypeScript and ready for the web.",
"version": "1.0.2",
"version": "1.0.3",
"main": "cjs/index.js",

@@ -26,3 +26,3 @@ "module": "esm/index.js",

"sideEffects": false,
"gitHead": "58fac96eb7ac16ab749cfe7c75db79bd9e3bb3c6"
"gitHead": "fbf9816c976a9569f2ef61df59f0e6d6251ef8e9"
}

@@ -33,3 +33,3 @@ import { CHAR_FORWARD_SLASH, CHAR_DOT, sep } from './constants';

let dots = 0;
let code: number | undefined;
let code = 0;
for (let i = 0; i <= path.length; ++i) {

@@ -39,3 +39,2 @@ if (i < path.length) {

} else if (code === CHAR_FORWARD_SLASH) {
// isPosixPathSeparator
break;

@@ -47,6 +46,5 @@ } else {

if (code === CHAR_FORWARD_SLASH) {
// isPosixPathSeparator
if (lastSlash === i - 1 || dots === 1) {
// NOOP
} else if (lastSlash !== i - 1 && dots === 2) {
} else if (dots === 2) {
if (

@@ -70,3 +68,3 @@ res.length < 2 ||

continue;
} else if (res.length === 2 || res.length === 1) {
} else if (res.length !== 0) {
res = '';

@@ -73,0 +71,0 @@ lastSegmentLength = 0;

@@ -8,21 +8,17 @@ import { CHAR_FORWARD_SLASH } from './constants';

}
// Trim leading forward slashes.
from = resolve(from);
to = resolve(to);
if (from === to) {
return '';
}
// Trim any leading backslashes
let fromStart = 1;
while (fromStart < from.length && from.charCodeAt(fromStart) === CHAR_FORWARD_SLASH) {
fromStart++;
}
const fromStart = 1;
const fromEnd = from.length;
const fromLen = fromEnd - fromStart;
// Trim any leading backslashes
let toStart = 1;
while (toStart < to.length && to.charCodeAt(toStart) === CHAR_FORWARD_SLASH) {
toStart++;
}
const toEnd = to.length;
const toLen = toEnd - toStart;
const toStart = 1;
const toLen = to.length - toStart;
// Compare paths to find the longest common path from root

@@ -52,17 +48,12 @@ const length = fromLen < toLen ? fromLen : toLen;

}
} else if (fromLen > length) {
if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
// We get here if `to` is the exact base path for `from`.
// For example: from='/foo/bar/baz'; to='/foo/bar'
lastCommonSep = i;
} else if (i === 0) {
// We get here if `to` is the root.
// For example: from='/foo'; to='/'
lastCommonSep = 0;
}
} else if (fromLen > length && from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
// We get here if `to` is the exact base path for `from`.
// For example: from='/foo/bar/baz'; to='/foo/bar'
lastCommonSep = i;
}
}
let out = '';
// Generate the relative path based on the path difference between `to`
// and `from`
// and `from`.
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {

@@ -73,12 +64,6 @@ if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {

}
toStart += lastCommonSep;
// Lastly, append the rest of the destination (`to`) path that comes after
// the common path parts
if (out.length > 0) {
return `${out}${to.slice(toStart)}`;
}
if (to.charCodeAt(toStart) === CHAR_FORWARD_SLASH) {
++toStart;
}
return to.slice(toStart);
// the common path parts.
return `${out}${to.slice(toStart + lastCommonSep)}`;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc