/
githubmirror
/
ydb-embedded-ui
Обзор
Документация
Войти
/
githubmirror
/
ydb-embedded-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/containers/Tenant/ObjectSummary/transformPath.ts
32 строки
1 KB
Konstantin Kozlov
feat: implement new "Info" tabs for all object types in the database tree (#4136)
27 июл 2026, 08:58
Не верифицирован
27 июл 2026, 08:58
9d7ce19
Код
Авторство
О чём код?
import {EPathType} from '../../../types/api/schema'; export function transformPath(path: string, databaseFullPath: string): string { // Normalize the path and dbName by removing leading/trailing slashes const normalizedPath = path.replace(/^\/+|\/+$/g, ''); const normalizedDbName = databaseFullPath.replace(/^\/+|\/+$/g, ''); if (!normalizedPath.startsWith(normalizedDbName)) { return normalizedPath || '/'; } if (normalizedPath === normalizedDbName) { return `/${normalizedPath}`; } let result = normalizedPath.slice(normalizedDbName.length); // Remove leading slash if present, unless the result would be empty result = result.replace(/^\/+/, '') || '/'; return result; } export function isDomain(path: string, type?: EPathType) { if (type !== EPathType.EPathTypeDir) { return false; } return path.split('/').length === 2 && path.startsWith('/'); } export function getPathTypeName(path: string, type?: EPathType) { return isDomain(path, type) ? 'Domain' : type?.replace(/^EPathType/, ''); }