isSubpath.js 273 B

12345678910111213
  1. 'use strict';
  2. /*!
  3. * Determines if `path2` is a subpath of or equal to `path1`
  4. *
  5. * @param {string} path1
  6. * @param {string} path2
  7. * @return {Boolean}
  8. */
  9. module.exports = function isSubpath(path1, path2) {
  10. return path1 === path2 || path2.startsWith(path1 + '.');
  11. };