Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

index.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.replacePathSepForRegex =
  6. exports.escapeStrForRegex =
  7. exports.escapePathForRegex =
  8. void 0;
  9. var _path = require('path');
  10. /**
  11. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  12. *
  13. * This source code is licensed under the MIT license found in the
  14. * LICENSE file in the root directory of this source tree.
  15. *
  16. */
  17. const escapePathForRegex = dir => {
  18. if (_path.sep === '\\') {
  19. // Replace "\" with "/" so it's not escaped by escapeStrForRegex.
  20. // replacePathSepForRegex will convert it back.
  21. dir = dir.replace(/\\/g, '/');
  22. }
  23. return replacePathSepForRegex(escapeStrForRegex(dir));
  24. };
  25. exports.escapePathForRegex = escapePathForRegex;
  26. const escapeStrForRegex = string =>
  27. string.replace(/[[\]{}()*+?.\\^$|]/g, '\\$&');
  28. exports.escapeStrForRegex = escapeStrForRegex;
  29. const replacePathSepForRegex = string => {
  30. if (_path.sep === '\\') {
  31. return string.replace(
  32. /(\/|(.)?\\(?![[\]{}()*+?.^$|\\]))/g,
  33. (_match, _, p2) => (p2 && p2 !== '\\' ? p2 + '\\\\' : '\\\\')
  34. );
  35. }
  36. return string;
  37. };
  38. exports.replacePathSepForRegex = replacePathSepForRegex;