feat: adding utils module (string manipulation function)

This commit is contained in:
Mose Müller 2023-10-30 14:04:25 +01:00
parent 5b4c74f1c2
commit 7e5861ec22

View File

@ -0,0 +1,12 @@
export function getIdFromFullAccessPath(fullAccessPath: string) {
// 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;
}