'use strict';

var _path;

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

var _;

function _load_() {
  return _ = require('./');
}

var _constants;

function _load_constants() {
  return _constants = require('../constants');
}

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

module.exports = function (thePath, potentialParent) {
  // For inside-directory checking, we want to allow trailing slashes, so normalize.
  thePath = (0, (_ || _load_()).stripTrailingChar)(thePath, (_path || _load_path()).default.sep);
  potentialParent = (0, (_ || _load_()).stripTrailingChar)(potentialParent, (_path || _load_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 || _load_constants()).DEFAULT_SEPARATOR || thePath[potentialParent.length] === undefined);
};