You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
980 B

2 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.removeDuplicateSlashes = exports.transform = void 0;
  4. /**
  5. * Matches a sequence of two or more consecutive slashes, excluding the first two slashes at the beginning of the string.
  6. * The latter is due to the presence of the device path at the beginning of the UNC path.
  7. * @todo rewrite to negative lookbehind with the next major release.
  8. */
  9. const DOUBLE_SLASH_RE = /(?!^)\/{2,}/g;
  10. function transform(patterns) {
  11. return patterns.map((pattern) => removeDuplicateSlashes(pattern));
  12. }
  13. exports.transform = transform;
  14. /**
  15. * This package only works with forward slashes as a path separator.
  16. * Because of this, we cannot use the standard `path.normalize` method, because on Windows platform it will use of backslashes.
  17. */
  18. function removeDuplicateSlashes(pattern) {
  19. return pattern.replace(DOUBLE_SLASH_RE, '/');
  20. }
  21. exports.removeDuplicateSlashes = removeDuplicateSlashes;