pydase/frontend/src/utils/stringUtils.ts
Mose Müller 73a3283a7d feat: moving from react-create-app to vite
- loads of type fixes
- configuration changes
2024-07-04 16:45:00 +02:00

17 lines
422 B
TypeScript

export function getIdFromFullAccessPath(fullAccessPath: string) {
if (fullAccessPath) {
// Replace '].' with a single dash
let id = fullAccessPath.replace(/\]\./g, "-");
// Replace any character that is not a word character or underscore with a dash
id = id.replace(/[^\w_]+/g, "-");
// Remove any trailing dashes
id = id.replace(/-+$/, "");
return id;
} else {
return "main";
}
}