@stryke/path 0.25.1 → 0.25.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  # Changelog for Stryke - Path
4
4
 
5
+ ## [0.25.2](https://github.com/storm-software/stryke/releases/tag/path%400.25.2) (01/16/2026)
6
+
7
+ ### Bug Fixes
8
+
9
+ - **path:** Resolve issue updating characters in `globToRegex` function
10
+ ([85ce0869](https://github.com/storm-software/stryke/commit/85ce0869))
11
+
12
+ ## [0.25.1](https://github.com/storm-software/stryke/releases/tag/path%400.25.1) (01/16/2026)
13
+
14
+ ### Updated Dependencies
15
+
16
+ - Updated **type-checks** to **v0.5.19**
17
+ - Updated **convert** to **v0.6.34**
18
+ - Updated **types** to **v0.10.33**
19
+
5
20
  ## [0.25.0](https://github.com/storm-software/stryke/releases/tag/path%400.25.0) (01/16/2026)
6
21
 
7
22
  ### Features
@@ -27,16 +27,11 @@ const require_is_set_string = require('./type-checks/src/is-set-string.cjs');
27
27
  */
28
28
  function globToRegex(glob, options = {}) {
29
29
  if (!require_is_set_string.isSetString(glob)) throw new TypeError("A string was not provided as a glob pattern.");
30
- const str = String(glob);
31
30
  let regex = "";
32
31
  let inGroup = false;
33
- let char;
34
- for (let i = 0, len = str.length; i < len; i++) {
35
- char = str[i];
36
- const prevChar = str[i - 1];
37
- const nextChar = str[i + 1];
38
- let starCount = 1;
39
- switch (char) {
32
+ for (let i = 0; i < glob.length; i++) {
33
+ let count = 1;
34
+ switch (glob[i]) {
40
35
  case "/":
41
36
  case "$":
42
37
  case "^":
@@ -47,14 +42,14 @@ function globToRegex(glob, options = {}) {
47
42
  case "=":
48
43
  case "!":
49
44
  case "|":
50
- regex += `\\${char}`;
45
+ regex += `\\${glob[i]}`;
51
46
  break;
52
47
  case "?":
53
48
  if (options.extended !== false) regex += ".";
54
49
  break;
55
50
  case "[":
56
51
  case "]":
57
- if (options.extended !== false) regex += char;
52
+ if (options.extended !== false) regex += glob[i];
58
53
  break;
59
54
  case "{":
60
55
  if (options.extended !== false) {
@@ -70,22 +65,21 @@ function globToRegex(glob, options = {}) {
70
65
  break;
71
66
  case ",":
72
67
  if (inGroup) regex += "|";
73
- regex += `\\${char}`;
68
+ regex += `\\${glob[i]}`;
74
69
  break;
75
70
  case "*":
76
- starCount = 1;
77
- while (str[i + 1] === "*") {
78
- starCount++;
71
+ while (glob[i + 1] === "*") {
72
+ count++;
79
73
  i++;
80
74
  }
81
75
  if (options.globstar === false) regex += ".*";
82
- else if (starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0)) {
83
- regex += "((?:[^/]*(?:/|$))*)?";
76
+ else if (count > 1 && i - count >= 0 && (glob[i - count] === "/" || glob[i - count] === void 0) && i + 1 < glob.length && (glob[i + 1] === "/" || glob[i + 1] === void 0)) {
77
+ regex += "((?:[^/]*(?:/|$))*)";
84
78
  i++;
85
79
  } else regex += "([^/]*)";
86
80
  break;
87
81
  case void 0:
88
- default: regex += char;
82
+ default: regex += glob[i];
89
83
  }
90
84
  }
91
85
  const flags = require_is_set_string.isSetString(options.flags) ? options.flags : "";
@@ -27,16 +27,11 @@ import { isSetString } from "./type-checks/src/is-set-string.mjs";
27
27
  */
28
28
  function globToRegex(glob, options = {}) {
29
29
  if (!isSetString(glob)) throw new TypeError("A string was not provided as a glob pattern.");
30
- const str = String(glob);
31
30
  let regex = "";
32
31
  let inGroup = false;
33
- let char;
34
- for (let i = 0, len = str.length; i < len; i++) {
35
- char = str[i];
36
- const prevChar = str[i - 1];
37
- const nextChar = str[i + 1];
38
- let starCount = 1;
39
- switch (char) {
32
+ for (let i = 0; i < glob.length; i++) {
33
+ let count = 1;
34
+ switch (glob[i]) {
40
35
  case "/":
41
36
  case "$":
42
37
  case "^":
@@ -47,14 +42,14 @@ function globToRegex(glob, options = {}) {
47
42
  case "=":
48
43
  case "!":
49
44
  case "|":
50
- regex += `\\${char}`;
45
+ regex += `\\${glob[i]}`;
51
46
  break;
52
47
  case "?":
53
48
  if (options.extended !== false) regex += ".";
54
49
  break;
55
50
  case "[":
56
51
  case "]":
57
- if (options.extended !== false) regex += char;
52
+ if (options.extended !== false) regex += glob[i];
58
53
  break;
59
54
  case "{":
60
55
  if (options.extended !== false) {
@@ -70,22 +65,21 @@ function globToRegex(glob, options = {}) {
70
65
  break;
71
66
  case ",":
72
67
  if (inGroup) regex += "|";
73
- regex += `\\${char}`;
68
+ regex += `\\${glob[i]}`;
74
69
  break;
75
70
  case "*":
76
- starCount = 1;
77
- while (str[i + 1] === "*") {
78
- starCount++;
71
+ while (glob[i + 1] === "*") {
72
+ count++;
79
73
  i++;
80
74
  }
81
75
  if (options.globstar === false) regex += ".*";
82
- else if (starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0)) {
83
- regex += "((?:[^/]*(?:/|$))*)?";
76
+ else if (count > 1 && i - count >= 0 && (glob[i - count] === "/" || glob[i - count] === void 0) && i + 1 < glob.length && (glob[i + 1] === "/" || glob[i + 1] === void 0)) {
77
+ regex += "((?:[^/]*(?:/|$))*)";
84
78
  i++;
85
79
  } else regex += "([^/]*)";
86
80
  break;
87
81
  case void 0:
88
- default: regex += char;
82
+ default: regex += glob[i];
89
83
  }
90
84
  }
91
85
  const flags = isSetString(options.flags) ? options.flags : "";
@@ -1 +1 @@
1
- {"version":3,"file":"glob-to-regex.mjs","names":["char: string | undefined"],"sources":["../src/glob-to-regex.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\n\n/**\n * Options for the `globToRegex` function.\n */\nexport interface GlobToRegexOptions {\n /**\n * Enables extended globbing features such as `?`, `+`, `@`, and `!`.\n *\n * @defaultValue true\n */\n extended?: boolean;\n\n /**\n * Enables globstar support (`**`).\n *\n * @defaultValue true\n */\n globstar?: boolean;\n\n /**\n * Flags to use for the generated regular expression.\n */\n flags?: string;\n}\n\n/**\n * Converts a glob pattern to a regular expression.\n *\n * @see https://mergify.com/blog/origin-and-evolution-of-the-globstar\n * @see https://en.wikipedia.org/wiki/Glob_(programming)\n *\n * @remarks\n * This function converts a glob pattern (like `*.{js,ts}` or `**\\/src/**`) into a regular expression\n *\n * @example\n * ```ts\n * import { globToRegex } from \"@stryke/path/glob-to-regex\";\n *\n * const test1 = globToRegex(\"*.{js,ts}\");\n * console.log(test1); // Output: /^([^/]*)\\.(js|ts)$/\n *\n * const test2 = globToRegex(\"**\\/src/**\");\n * console.log(test2); // Output: /^((?:[^/]*(?:\\/|$))*)?\\/src\\/((?:[^/]*(?:\\/|$))*)?$/\n * ```\n *\n * @param glob - The glob pattern to convert.\n * @param options - The options for the conversion.\n * @returns The converted regular expression.\n */\nexport function globToRegex(\n glob: string,\n options: GlobToRegexOptions = {}\n): RegExp {\n if (!isSetString(glob)) {\n throw new TypeError(\"A string was not provided as a glob pattern.\");\n }\n\n const str = String(glob);\n let regex = \"\";\n\n let inGroup = false;\n let char: string | undefined;\n for (let i = 0, len = str.length; i < len; i++) {\n char = str[i];\n\n const prevChar = str[i - 1];\n const nextChar = str[i + 1];\n let starCount = 1;\n\n switch (char) {\n case \"/\":\n case \"$\":\n case \"^\":\n case \"+\":\n case \".\":\n case \"(\":\n case \")\":\n case \"=\":\n case \"!\":\n case \"|\":\n regex += `\\\\${char}`;\n break;\n\n case \"?\":\n if (options.extended !== false) {\n regex += \".\";\n }\n break;\n\n case \"[\":\n case \"]\":\n if (options.extended !== false) {\n regex += char;\n }\n break;\n\n case \"{\":\n if (options.extended !== false) {\n inGroup = true;\n regex += \"(\";\n }\n break;\n\n case \"}\":\n if (options.extended !== false) {\n inGroup = false;\n regex += \")\";\n }\n break;\n\n case \",\":\n if (inGroup) {\n regex += \"|\";\n }\n regex += `\\\\${char}`;\n break;\n\n case \"*\":\n starCount = 1;\n while (str[i + 1] === \"*\") {\n starCount++;\n i++;\n }\n\n if (options.globstar === false) {\n regex += \".*\";\n } else {\n const isGlobstar =\n starCount > 1 &&\n (prevChar === \"/\" || prevChar === undefined) &&\n (nextChar === \"/\" || nextChar === undefined);\n\n if (isGlobstar) {\n regex += \"((?:[^/]*(?:\\/|$))*)?\";\n i++;\n } else {\n regex += \"([^/]*)\";\n }\n }\n break;\n\n case undefined:\n default:\n regex += char;\n }\n }\n\n const flags = isSetString(options.flags) ? options.flags : \"\";\n if (!flags || !~flags.indexOf(\"g\")) {\n regex = `^${regex}$`;\n }\n\n return new RegExp(regex, flags);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,SAAgB,YACd,MACA,UAA8B,EAAE,EACxB;AACR,KAAI,CAAC,YAAY,KAAK,CACpB,OAAM,IAAI,UAAU,+CAA+C;CAGrE,MAAM,MAAM,OAAO,KAAK;CACxB,IAAI,QAAQ;CAEZ,IAAI,UAAU;CACd,IAAIA;AACJ,MAAK,IAAI,IAAI,GAAG,MAAM,IAAI,QAAQ,IAAI,KAAK,KAAK;AAC9C,SAAO,IAAI;EAEX,MAAM,WAAW,IAAI,IAAI;EACzB,MAAM,WAAW,IAAI,IAAI;EACzB,IAAI,YAAY;AAEhB,UAAQ,MAAR;GACE,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;AACH,aAAS,KAAK;AACd;GAEF,KAAK;AACH,QAAI,QAAQ,aAAa,MACvB,UAAS;AAEX;GAEF,KAAK;GACL,KAAK;AACH,QAAI,QAAQ,aAAa,MACvB,UAAS;AAEX;GAEF,KAAK;AACH,QAAI,QAAQ,aAAa,OAAO;AAC9B,eAAU;AACV,cAAS;;AAEX;GAEF,KAAK;AACH,QAAI,QAAQ,aAAa,OAAO;AAC9B,eAAU;AACV,cAAS;;AAEX;GAEF,KAAK;AACH,QAAI,QACF,UAAS;AAEX,aAAS,KAAK;AACd;GAEF,KAAK;AACH,gBAAY;AACZ,WAAO,IAAI,IAAI,OAAO,KAAK;AACzB;AACA;;AAGF,QAAI,QAAQ,aAAa,MACvB,UAAS;aAGP,YAAY,MACX,aAAa,OAAO,aAAa,YACjC,aAAa,OAAO,aAAa,SAEpB;AACd,cAAS;AACT;UAEA,UAAS;AAGb;GAEF,KAAK;GACL,QACE,UAAS;;;CAIf,MAAM,QAAQ,YAAY,QAAQ,MAAM,GAAG,QAAQ,QAAQ;AAC3D,KAAI,CAAC,SAAS,CAAC,CAAC,MAAM,QAAQ,IAAI,CAChC,SAAQ,IAAI,MAAM;AAGpB,QAAO,IAAI,OAAO,OAAO,MAAM"}
1
+ {"version":3,"file":"glob-to-regex.mjs","names":[],"sources":["../src/glob-to-regex.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\n\n/**\n * Options for the `globToRegex` function.\n */\nexport interface GlobToRegexOptions {\n /**\n * Enables extended globbing features such as `?`, `+`, `@`, and `!`.\n *\n * @defaultValue true\n */\n extended?: boolean;\n\n /**\n * Enables globstar support (`**`).\n *\n * @defaultValue true\n */\n globstar?: boolean;\n\n /**\n * Flags to use for the generated regular expression.\n */\n flags?: string;\n}\n\n/**\n * Converts a glob pattern to a regular expression.\n *\n * @see https://mergify.com/blog/origin-and-evolution-of-the-globstar\n * @see https://en.wikipedia.org/wiki/Glob_(programming)\n *\n * @remarks\n * This function converts a glob pattern (like `*.{js,ts}` or `**\\/src/**`) into a regular expression\n *\n * @example\n * ```ts\n * import { globToRegex } from \"@stryke/path/glob-to-regex\";\n *\n * const test1 = globToRegex(\"*.{js,ts}\");\n * console.log(test1); // Output: /^([^/]*)\\.(js|ts)$/\n *\n * const test2 = globToRegex(\"**\\/src/**\");\n * console.log(test2); // Output: /^((?:[^/]*(?:\\/|$))*)?\\/src\\/((?:[^/]*(?:\\/|$))*)?$/\n * ```\n *\n * @param glob - The glob pattern to convert.\n * @param options - The options for the conversion.\n * @returns The converted regular expression.\n */\nexport function globToRegex(\n glob: string,\n options: GlobToRegexOptions = {}\n): RegExp {\n if (!isSetString(glob)) {\n throw new TypeError(\"A string was not provided as a glob pattern.\");\n }\n\n let regex = \"\";\n let inGroup = false;\n for (let i = 0; i < glob.length; i++) {\n let count = 1;\n switch (glob[i]) {\n case \"/\":\n case \"$\":\n case \"^\":\n case \"+\":\n case \".\":\n case \"(\":\n case \")\":\n case \"=\":\n case \"!\":\n case \"|\":\n regex += `\\\\${glob[i]}`;\n break;\n\n case \"?\":\n if (options.extended !== false) {\n regex += \".\";\n }\n break;\n\n case \"[\":\n case \"]\":\n if (options.extended !== false) {\n regex += glob[i];\n }\n break;\n\n case \"{\":\n if (options.extended !== false) {\n inGroup = true;\n regex += \"(\";\n }\n break;\n\n case \"}\":\n if (options.extended !== false) {\n inGroup = false;\n regex += \")\";\n }\n break;\n\n case \",\":\n if (inGroup) {\n regex += \"|\";\n }\n regex += `\\\\${glob[i]}`;\n break;\n\n case \"*\":\n while (glob[i + 1] === \"*\") {\n count++;\n i++;\n }\n\n if (options.globstar === false) {\n regex += \".*\";\n } else if (\n count > 1 &&\n i - count >= 0 &&\n (glob[i - count] === \"/\" || glob[i - count] === undefined) &&\n i + 1 < glob.length &&\n (glob[i + 1] === \"/\" || glob[i + 1] === undefined)\n ) {\n regex += \"((?:[^\\/]*(?:\\/|$))*)\";\n i++;\n } else {\n regex += \"([^\\/]*)\";\n }\n\n break;\n\n case undefined:\n default:\n regex += glob[i];\n }\n }\n\n const flags = isSetString(options.flags) ? options.flags : \"\";\n if (!flags || !~flags.indexOf(\"g\")) {\n regex = `^${regex}$`;\n }\n\n return new RegExp(regex, flags);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,SAAgB,YACd,MACA,UAA8B,EAAE,EACxB;AACR,KAAI,CAAC,YAAY,KAAK,CACpB,OAAM,IAAI,UAAU,+CAA+C;CAGrE,IAAI,QAAQ;CACZ,IAAI,UAAU;AACd,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,IAAI,QAAQ;AACZ,UAAQ,KAAK,IAAb;GACE,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;AACH,aAAS,KAAK,KAAK;AACnB;GAEF,KAAK;AACH,QAAI,QAAQ,aAAa,MACvB,UAAS;AAEX;GAEF,KAAK;GACL,KAAK;AACH,QAAI,QAAQ,aAAa,MACvB,UAAS,KAAK;AAEhB;GAEF,KAAK;AACH,QAAI,QAAQ,aAAa,OAAO;AAC9B,eAAU;AACV,cAAS;;AAEX;GAEF,KAAK;AACH,QAAI,QAAQ,aAAa,OAAO;AAC9B,eAAU;AACV,cAAS;;AAEX;GAEF,KAAK;AACH,QAAI,QACF,UAAS;AAEX,aAAS,KAAK,KAAK;AACnB;GAEF,KAAK;AACH,WAAO,KAAK,IAAI,OAAO,KAAK;AAC1B;AACA;;AAGF,QAAI,QAAQ,aAAa,MACvB,UAAS;aAET,QAAQ,KACR,IAAI,SAAS,MACZ,KAAK,IAAI,WAAW,OAAO,KAAK,IAAI,WAAW,WAChD,IAAI,IAAI,KAAK,WACZ,KAAK,IAAI,OAAO,OAAO,KAAK,IAAI,OAAO,SACxC;AACA,cAAS;AACT;UAEA,UAAS;AAGX;GAEF,KAAK;GACL,QACE,UAAS,KAAK;;;CAIpB,MAAM,QAAQ,YAAY,QAAQ,MAAM,GAAG,QAAQ,QAAQ;AAC3D,KAAI,CAAC,SAAS,CAAC,CAAC,MAAM,QAAQ,IAAI,CAChC,SAAQ,IAAI,MAAM;AAGpB,QAAO,IAAI,OAAO,OAAO,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/path",
3
- "version": "0.25.1",
3
+ "version": "0.25.3",
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": {
@@ -85,5 +85,5 @@
85
85
  "tsdown": "^0.17.2"
86
86
  },
87
87
  "publishConfig": { "access": "public" },
88
- "gitHead": "9c02f25b3bf83a1228a94fc2ef3fcd816dc0f707"
88
+ "gitHead": "e0cedae14a70843b0d60ab6d8d36ec368d230310"
89
89
  }