@stryke/path 0.18.0 → 0.18.1

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.
@@ -29,7 +29,7 @@ function stripStars(e) {
29
29
  if (!e || e.length === 0) return ".";
30
30
  e = correctPath(e);
31
31
  let t = !1;
32
- return e.split("/").reduce((r, n) => n?.trim() ? t || n.includes("*") ? (t = !0, r) : r + (r.length > 0 ? `/${n}` : n) : r, "");
32
+ return e.split("/").reduce((r, n) => n?.trim() ? t || n.includes("*") ? (t = !0, r) : r + (r ? `/${n}` : n) : r, "");
33
33
  }
34
34
  function normalizeString(e, t) {
35
35
  let r = "",
@@ -1 +1 @@
1
- import{cwd as m}from"./cwd";import{isAbsolutePath as u}from"./is-type";import{joinPaths as g}from"./join-paths";import{DRIVE_LETTER_REGEX as d,DRIVE_LETTER_START_REGEX as E,UNC_REGEX as x}from"./regex";import{slash as f}from"./slash";export function normalizeWindowsPath(e=""){return e&&f(e).replace(E,t=>t.toUpperCase())}export function correctPath(e){if(!e||e.length===0)return".";e=normalizeWindowsPath(e);const t=e.match(x),r=u(e),n=e.endsWith("/");return e=normalizeString(e,!r),e.length===0?r?"/":n?"./":".":(n&&(e+="/"),d.test(e)&&(e+="/"),t?r?`//${e}`:`//./${e}`:!e.startsWith("/")&&r&&!d.test(e)?`/${e}`:e)}export function stripStars(e){if(!e||e.length===0)return".";e=correctPath(e);let t=!1;return e.split("/").reduce((r,n)=>n?.trim()?t||n.includes("*")?(t=!0,r):r+(r.length>0?`/${n}`:n):r,"")}export function normalizeString(e,t){let r="",n=0,l=-1,s=0,o=null;for(let i=0;i<=e.length;++i){if(i<e.length)o=e[i];else{if(o==="/")break;o="/"}if(o==="/"){if(!(l===i-1||s===1))if(s===2){if(r.length<2||n!==2||r[r.length-1]!=="."||r[r.length-2]!=="."){if(r.length>2){const c=r.lastIndexOf("/");c===-1?(r="",n=0):(r=r.slice(0,c),n=r.length-1-r.lastIndexOf("/")),l=i,s=0;continue}else if(r.length>0){r="",n=0,l=i,s=0;continue}}t&&(r+=r.length>0?"/..":"..",n=2)}else r.length>0?r+=`/${e.slice(l+1,i)}`:r=e.slice(l+1,i),n=i-l-1;l=i,s=0}else o==="."&&s!==-1?++s:s=-1}return r}export function toAbsolutePath(e,t){return u(e)?e:f(normalizeString(g(t||process.cwd(),e),!0))}export function toRelativePath(e,t=m()){return!e||e.length===0?".":(u(e)?e=f(normalizeString(e,!0)):e=f(normalizeString(g(t,e),!0)),e.startsWith("./")?e.slice(2):e)}
1
+ import{cwd as m}from"./cwd";import{isAbsolutePath as u}from"./is-type";import{joinPaths as g}from"./join-paths";import{DRIVE_LETTER_REGEX as d,DRIVE_LETTER_START_REGEX as E,UNC_REGEX as x}from"./regex";import{slash as f}from"./slash";export function normalizeWindowsPath(e=""){return e&&f(e).replace(E,t=>t.toUpperCase())}export function correctPath(e){if(!e||e.length===0)return".";e=normalizeWindowsPath(e);const t=e.match(x),r=u(e),n=e.endsWith("/");return e=normalizeString(e,!r),e.length===0?r?"/":n?"./":".":(n&&(e+="/"),d.test(e)&&(e+="/"),t?r?`//${e}`:`//./${e}`:!e.startsWith("/")&&r&&!d.test(e)?`/${e}`:e)}export function stripStars(e){if(!e||e.length===0)return".";e=correctPath(e);let t=!1;return e.split("/").reduce((r,n)=>n?.trim()?t||n.includes("*")?(t=!0,r):r+(r?`/${n}`:n):r,"")}export function normalizeString(e,t){let r="",n=0,l=-1,s=0,o=null;for(let i=0;i<=e.length;++i){if(i<e.length)o=e[i];else{if(o==="/")break;o="/"}if(o==="/"){if(!(l===i-1||s===1))if(s===2){if(r.length<2||n!==2||r[r.length-1]!=="."||r[r.length-2]!=="."){if(r.length>2){const c=r.lastIndexOf("/");c===-1?(r="",n=0):(r=r.slice(0,c),n=r.length-1-r.lastIndexOf("/")),l=i,s=0;continue}else if(r.length>0){r="",n=0,l=i,s=0;continue}}t&&(r+=r.length>0?"/..":"..",n=2)}else r.length>0?r+=`/${e.slice(l+1,i)}`:r=e.slice(l+1,i),n=i-l-1;l=i,s=0}else o==="."&&s!==-1?++s:s=-1}return r}export function toAbsolutePath(e,t){return u(e)?e:f(normalizeString(g(t||process.cwd(),e),!0))}export function toRelativePath(e,t=m()){return!e||e.length===0?".":(u(e)?e=f(normalizeString(e,!0)):e=f(normalizeString(g(t,e),!0)),e.startsWith("./")?e.slice(2):e)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/path",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "type": "module",
5
5
  "description": "A package containing various utilities that expand the functionality of NodeJs's built-in `path` module",
6
6
  "repository": {
@@ -10,6 +10,7 @@
10
10
  },
11
11
  "private": false,
12
12
  "devDependencies": {
13
+ "@storm-software/testing-tools": "^1.119.14",
13
14
  "@stryke/convert": "^0.6.0",
14
15
  "@stryke/type-checks": "^0.3.10",
15
16
  "@stryke/types": "^0.10.0"
@@ -279,5 +280,5 @@
279
280
  "main": "./dist/index.cjs",
280
281
  "module": "./dist/index.mjs",
281
282
  "types": "./dist/index.d.ts",
282
- "gitHead": "04107da5bbf439fe7e705783009e18fc5080a4fe"
283
+ "gitHead": "1764a8373c1db0b1c11bed7439292236edfd9e4e"
283
284
  }