file.js 708 B

12345678910111213141516171819202122
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.fileUtils = void 0;
  4. class FileUtils {
  5. constructor() {
  6. this.filenameReservedRegex = (/[<>:"\/\\|?*\x00-\x1F]/g);
  7. this.filenameReservedRegexWindows = (/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i);
  8. }
  9. isValidFileName(fileName) {
  10. if (!fileName || fileName.length > 255) {
  11. return false;
  12. }
  13. if (this.filenameReservedRegex.test(fileName) || this.filenameReservedRegexWindows.test(fileName)) {
  14. return false;
  15. }
  16. if (/^\.\.?$/.test(fileName)) {
  17. return false;
  18. }
  19. return true;
  20. }
  21. }
  22. exports.fileUtils = new FileUtils();