1"use strict"; 2Object.defineProperty(exports, "__esModule", { value: true }); 3exports.escape = void 0; 4/** 5 * Escape all magic characters in a glob pattern. 6 * 7 * If the {@link windowsPathsNoEscape | GlobOptions.windowsPathsNoEscape} 8 * option is used, then characters are escaped by wrapping in `[]`, because 9 * a magic character wrapped in a character class can only be satisfied by 10 * that exact character. In this mode, `\` is _not_ escaped, because it is 11 * not interpreted as a magic character, but instead as a path separator. 12 */ 13const escape = (s, { windowsPathsNoEscape = false, } = {}) => { 14 // don't need to escape +@! because we escape the parens 15 // that make those magic, and escaping ! as [!] isn't valid, 16 // because [!]] is a valid glob class meaning not ']'. 17 return windowsPathsNoEscape 18 ? s.replace(/[?*()[\]]/g, '[$&]') 19 : s.replace(/[?*()[\]\\]/g, '\\$&'); 20}; 21exports.escape = escape; 22//# sourceMappingURL=escape.js.map