@karmaniverous/jeeves-meta 0.11.1 → 0.11.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.
@@ -845,13 +845,19 @@ async function listMetas(config, watcher) {
845
845
  * @module escapeGlob
846
846
  */
847
847
  /**
848
- * Escape glob metacharacters in a string.
848
+ * Escape glob metacharacters in a string using character-class wrapping.
849
+ *
850
+ * Backslash escaping (`\(`) does not work reliably on Windows where `\` is
851
+ * the path separator. Instead, each metacharacter is wrapped in a character
852
+ * class (e.g. `(` → `[(]`) which is universally supported by glob libraries.
853
+ *
854
+ * Square brackets themselves are escaped as `[[]` and `[]]`.
849
855
  *
850
856
  * @param s - Raw path string.
851
- * @returns String with glob metacharacters backslash-escaped.
857
+ * @returns String with glob metacharacters wrapped in character classes.
852
858
  */
853
859
  function escapeGlob(s) {
854
- return s.replace(/[*?[\]{}()!]/g, '\\$&');
860
+ return s.replace(/[*?[\]{}()!]/g, (ch) => `[${ch}]`);
855
861
  }
856
862
 
857
863
  /**
package/dist/index.js CHANGED
@@ -837,13 +837,19 @@ async function listMetas(config, watcher) {
837
837
  * @module escapeGlob
838
838
  */
839
839
  /**
840
- * Escape glob metacharacters in a string.
840
+ * Escape glob metacharacters in a string using character-class wrapping.
841
+ *
842
+ * Backslash escaping (`\(`) does not work reliably on Windows where `\` is
843
+ * the path separator. Instead, each metacharacter is wrapped in a character
844
+ * class (e.g. `(` → `[(]`) which is universally supported by glob libraries.
845
+ *
846
+ * Square brackets themselves are escaped as `[[]` and `[]]`.
841
847
  *
842
848
  * @param s - Raw path string.
843
- * @returns String with glob metacharacters backslash-escaped.
849
+ * @returns String with glob metacharacters wrapped in character classes.
844
850
  */
845
851
  function escapeGlob(s) {
846
- return s.replace(/[*?[\]{}()!]/g, '\\$&');
852
+ return s.replace(/[*?[\]{}()!]/g, (ch) => `[${ch}]`);
847
853
  }
848
854
 
849
855
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karmaniverous/jeeves-meta",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "author": "Jason Williscroft",
5
5
  "description": "Fastify HTTP service for the Jeeves Meta synthesis engine",
6
6
  "license": "BSD-3-Clause",