"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = isValidPath;

function _path() {
  const data = _interopRequireDefault(require("path"));

  _path = function () {
    return data;
  };

  return data;
}

function _ramda() {
  const data = _interopRequireDefault(require("ramda"));

  _ramda = function () {
    return data;
  };

  return data;
}

const MAX_LENGTH = 4096;
/**
 * most are invalid for Windows, but it's a good idea to be compatible with both
 */

const INVALID_CHARS = ['<', '>', '|', '?', '*', ':', '"'];
/**
 * relevant for mainFile, rootDir and files relative-paths. Either in bitmap or in the model.
 * 1) it can't be absolute
 * 2) it must be linux format (`\` is forbidden)
 * 3) it can't point to a parent directory (`../`) or current directory (`./`)
 */

function isValidPath(pathStr) {
  if (!pathStr || !_ramda().default.is(String, pathStr) || INVALID_CHARS.some(c => pathStr.includes(c)) || pathStr.length > MAX_LENGTH || _path().default.isAbsolute(pathStr) || pathStr.startsWith('./') || pathStr.startsWith('../') || pathStr.includes('\\')) {
    return false;
  }

  return true;
}