source: node_modules/minimatch/dist/commonjs/escape.js@ 81bc7da

finki-main main
Last change on this file since 81bc7da was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[81bc7da]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 MinimatchOptions.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 *
13 * If the {@link MinimatchOptions.magicalBraces} option is used,
14 * then braces (`{` and `}`) will be escaped.
15 */
16const escape = (s, { windowsPathsNoEscape = false, magicalBraces = false, } = {}) => {
17 // don't need to escape +@! because we escape the parens
18 // that make those magic, and escaping ! as [!] isn't valid,
19 // because [!]] is a valid glob class meaning not ']'.
20 if (magicalBraces) {
21 return windowsPathsNoEscape ?
22 s.replace(/[?*()[\]{}]/g, '[$&]')
23 : s.replace(/[?*()[\]\\{}]/g, '\\$&');
24 }
25 return windowsPathsNoEscape ?
26 s.replace(/[?*()[\]]/g, '[$&]')
27 : s.replace(/[?*()[\]\\]/g, '\\$&');
28};
29exports.escape = escape;
30//# sourceMappingURL=escape.js.map
Note: See TracBrowser for help on using the repository browser.