fix: match root project sessions in switcher (#1274)
* fix: match root project sessions in switcher * test: cover project path matching edge cases --------- Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
9c71119835
commit
00c112077d
@@ -81,6 +81,15 @@ export const normalizePath = (value?: string | null) => {
|
||||
return normalized.length === 0 ? '/' : normalized;
|
||||
};
|
||||
|
||||
export const isPathWithinProject = (directory?: string | null, projectPath?: string | null): boolean => {
|
||||
const normalizedDirectory = normalizePath(directory);
|
||||
const normalizedProjectPath = normalizePath(projectPath);
|
||||
if (!normalizedDirectory || !normalizedProjectPath) return false;
|
||||
if (normalizedDirectory === normalizedProjectPath) return true;
|
||||
if (normalizedProjectPath === '/') return normalizedDirectory.startsWith('/');
|
||||
return normalizedDirectory.startsWith(`${normalizedProjectPath}/`);
|
||||
};
|
||||
|
||||
export const normalizeForBranchComparison = (value: string): string => {
|
||||
return value
|
||||
.toLowerCase()
|
||||
|
||||
Reference in New Issue
Block a user