mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-22 10:03:24 +01:00
17 lines
564 B
JavaScript
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
|