Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
unescape.js38 linesDownload Raw Back to commonjs
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.unescape = void 0;
4/**
5 * Un-escape a string that has been escaped with {@link escape}.
6 *
7 * If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
8 * square-bracket escapes are removed, but not backslash escapes.
9 *
10 * For example, it will turn the string `'[*]'` into `*`, but it will not
11 * turn `'\\*'` into `'*'`, because `\` is a path separator in
12 * `windowsPathsNoEscape` mode.
13 *
14 * When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
15 * backslash escapes are removed.
16 *
17 * Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
18 * or unescaped.
19 *
20 * When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
21 * unescaped.
22 */
23const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true, } = {}) => {
24    if (magicalBraces) {
25        return windowsPathsNoEscape ?
26            s.replace(/\[([^/\\])\]/g, '$1')
27            : s
28                .replace(/((?!\\).|^)\[([^/\\])\]/g, '$1$2')
29                .replace(/\\([^/])/g, '$1');
30    }
31    return windowsPathsNoEscape ?
32        s.replace(/\[([^/\\{}])\]/g, '$1')
33        : s
34            .replace(/((?!\\).|^)\[([^/\\{}])\]/g, '$1$2')
35            .replace(/\\([^/{}])/g, '$1');
36};
37exports.unescape = unescape;
38//# sourceMappingURL=unescape.js.map
codekingpro/portable-devtools · Team Ai