"use strict";

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

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

  _path = function () {
    return data;
  };

  return data;
}

function _stripTrailingChar() {
  const data = _interopRequireDefault(require("./string/strip-trailing-char"));

  _stripTrailingChar = function () {
    return data;
  };

  return data;
}

function _constants() {
  const data = require("../constants");

  _constants = function () {
    return data;
  };

  return data;
}

module.exports = function (thePath, potentialParent) {
  // For inside-directory checking, we want to allow trailing slashes, so normalize.
  thePath = (0, _stripTrailingChar().default)(thePath, _path().default.sep);
  potentialParent = (0, _stripTrailingChar().default)(potentialParent, _path().default.sep); // Node treats only Windows as case-insensitive in its path module; we follow those conventions.

  if (process.platform === 'win32') {
    thePath = thePath.toLowerCase();
    potentialParent = potentialParent.toLowerCase();
  }

  return thePath.lastIndexOf(potentialParent, 0) === 0 && (thePath[potentialParent.length] === _constants().DEFAULT_SEPARATOR || thePath[potentialParent.length] === undefined);
};