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