• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 windowsPathsNoEscape} option is used, then square-brace
8 * escapes are removed, but not backslash escapes.  For example, it will turn
9 * the string `'[*]'` into `*`, but it will not turn `'\\*'` into `'*'`,
10 * becuase `\` is a path separator in `windowsPathsNoEscape` mode.
11 *
12 * When `windowsPathsNoEscape` is not set, then both brace escapes and
13 * backslash escapes are removed.
14 *
15 * Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
16 * or unescaped.
17 */
18const unescape = (s, { windowsPathsNoEscape = false, } = {}) => {
19    return windowsPathsNoEscape
20        ? s.replace(/\[([^\/\\])\]/g, '$1')
21        : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, '$1$2').replace(/\\([^\/])/g, '$1');
22};
23exports.unescape = unescape;
24//# sourceMappingURL=unescape.js.map