wrangler-action/node_modules/is-subdir/index.js

18 lines
564 B
JavaScript
Raw Normal View History

2023-08-07 22:11:15 +02:00
'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