MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / isPathOutsideWorkspace

Function isPathOutsideWorkspace

src/utils/pathUtils.ts:9–24  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

7 * @returns true if the path is outside all workspace folders, false otherwise
8 */
9export function isPathOutsideWorkspace(filePath: string): boolean {
10 // If there are no workspace folders, consider everything outside workspace for safety
11 if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) {
12 return true
13 }
14
15 // Normalize and resolve the path to handle .. and . components correctly
16 const absolutePath = path.resolve(filePath)
17
18 // Check if the path is within any workspace folder
19 return !vscode.workspace.workspaceFolders.some((folder) => {
20 const folderPath = folder.uri.fsPath
21 // Path is inside a workspace if it equals the workspace path or is a subfolder
22 return absolutePath === folderPath || absolutePath.startsWith(folderPath + path.sep)
23 })
24}

Callers 15

executeMethod · 0.90
handlePartialMethod · 0.90
executeMethod · 0.90
handlePartialMethod · 0.90
requestApprovalMethod · 0.90
handlePartialMethod · 0.90
executeLegacyMethod · 0.90
executeMethod · 0.90
handlePartialMethod · 0.90
executeMethod · 0.90
handlePartialMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected