11cb0ef41Sopenharmony_ci/**
21cb0ef41Sopenharmony_ci * Escape all magic characters in a glob pattern.
31cb0ef41Sopenharmony_ci *
41cb0ef41Sopenharmony_ci * If the {@link windowsPathsNoEscape | GlobOptions.windowsPathsNoEscape}
51cb0ef41Sopenharmony_ci * option is used, then characters are escaped by wrapping in `[]`, because
61cb0ef41Sopenharmony_ci * a magic character wrapped in a character class can only be satisfied by
71cb0ef41Sopenharmony_ci * that exact character.  In this mode, `\` is _not_ escaped, because it is
81cb0ef41Sopenharmony_ci * not interpreted as a magic character, but instead as a path separator.
91cb0ef41Sopenharmony_ci */
101cb0ef41Sopenharmony_ciexport const escape = (s, { windowsPathsNoEscape = false, } = {}) => {
111cb0ef41Sopenharmony_ci    // don't need to escape +@! because we escape the parens
121cb0ef41Sopenharmony_ci    // that make those magic, and escaping ! as [!] isn't valid,
131cb0ef41Sopenharmony_ci    // because [!]] is a valid glob class meaning not ']'.
141cb0ef41Sopenharmony_ci    return windowsPathsNoEscape
151cb0ef41Sopenharmony_ci        ? s.replace(/[?*()[\]]/g, '[$&]')
161cb0ef41Sopenharmony_ci        : s.replace(/[?*()[\]\\]/g, '\\$&');
171cb0ef41Sopenharmony_ci};
181cb0ef41Sopenharmony_ci//# sourceMappingURL=escape.js.map