wrangler-action/node_modules/is-subdir/index.js
2023-08-07 15:11:15 -05:00

17 lines
564 B
JavaScript

'use strict'
const betterPathResolve = require('better-path-resolve')
const path = require('path')
function isSubdir (parentDir, subdir) {
const rParent = `${betterPathResolve(parentDir)}${path.sep}`
const rDir = `${betterPathResolve(subdir)}${path.sep}`
return rDir.startsWith(rParent)
}
isSubdir.strict = function isSubdirStrict (parentDir, subdir) {
const rParent = `${betterPathResolve(parentDir)}${path.sep}`
const rDir = `${betterPathResolve(subdir)}${path.sep}`
return rDir !== rParent && rDir.startsWith(rParent)
}
module.exports = isSubdir