MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / isWithinPath

Function isWithinPath

src/shared/utils/fs.ts:97–100  ·  view source on GitHub ↗
(file: string, folder: string)

Source from the content-addressed store, hash-verified

95}
96
97export function isWithinPath(file: string, folder: string) {
98 const relative = path.relative(folder.toLowerCase(), file.toLowerCase());
99 return !!relative && !relative.startsWith("..") && !path.isAbsolute(relative);
100}
101
102export function isWithinPathOrEqual(file: string, folder: string) {
103 const relative = path.relative(folder.toLowerCase(), file.toLowerCase());

Calls

no outgoing calls

Tested by

no test coverage detected