'use strict';

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

var _path;

function _load_path() {
  return _path = _interopRequireDefault(require('path'));
}

var _ramda;

function _load_ramda() {
  return _ramda = _interopRequireDefault(require('ramda'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var MAX_LENGTH = 4096;
/**
 * most are invalid for Windows, but it's a good idea to be compatible with both
 */
var 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 || _load_ramda()).default.is(String, pathStr) || INVALID_CHARS.some(function (c) {
    return pathStr.includes(c);
  }) || pathStr.length > MAX_LENGTH || (_path || _load_path()).default.isAbsolute(pathStr) || pathStr.startsWith('./') || pathStr.startsWith('../') || pathStr.includes('\\')) {
    return false;
  }
  return true;
}