isParentDirectory() — astro Function Reference
Architecture documentation for the isParentDirectory() function in path.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 4525e360_2c67_0c4f_35df_a9eadf0f5b45["isParentDirectory()"] f5377c99_3ce3_1abd_148f_93394ff5efe2["path.ts"] 4525e360_2c67_0c4f_35df_a9eadf0f5b45 -->|defined in| f5377c99_3ce3_1abd_148f_93394ff5efe2 d7463885_f985_b234_5ab2_077e4be21032["isRemotePath()"] 4525e360_2c67_0c4f_35df_a9eadf0f5b45 -->|calls| d7463885_f985_b234_5ab2_077e4be21032 d4571937_d638_60f3_9f40_6cef90ef9ba8["appendForwardSlash()"] 4525e360_2c67_0c4f_35df_a9eadf0f5b45 -->|calls| d4571937_d638_60f3_9f40_6cef90ef9ba8 d16d68ea_8270_46a2_8e2b_14cd92f2edaf["slash()"] 4525e360_2c67_0c4f_35df_a9eadf0f5b45 -->|calls| d16d68ea_8270_46a2_8e2b_14cd92f2edaf style 4525e360_2c67_0c4f_35df_a9eadf0f5b45 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/internal-helpers/src/path.ts lines 189–223
export function isParentDirectory(parentPath: string, childPath: string): boolean {
if (!parentPath || !childPath) {
return false;
}
// Reject any URLs
if (parentPath.includes('://') || childPath.includes('://')) {
return false;
}
// Reject remote or suspicious paths
if (isRemotePath(parentPath) || isRemotePath(childPath)) {
return false;
}
// Don't allow any .. in paths - too risky for traversal attacks
if (parentPath.includes('..') || childPath.includes('..')) {
return false;
}
// Reject null bytes - security risk
if (parentPath.includes('\0') || childPath.includes('\0')) {
return false;
}
const normalizedParent = appendForwardSlash(slash(parentPath).toLowerCase());
const normalizedChild = slash(childPath).toLowerCase();
// Don't allow same path (parent can't be parent of itself)
if (normalizedParent === normalizedChild || normalizedParent === normalizedChild + '/') {
return false;
}
return normalizedChild.startsWith(normalizedParent);
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does isParentDirectory() do?
isParentDirectory() is a function in the astro codebase, defined in packages/internal-helpers/src/path.ts.
Where is isParentDirectory() defined?
isParentDirectory() is defined in packages/internal-helpers/src/path.ts at line 189.
What does isParentDirectory() call?
isParentDirectory() calls 3 function(s): appendForwardSlash, isRemotePath, slash.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free