diff --git a/frontend/src/utils/stringUtils.ts b/frontend/src/utils/stringUtils.ts new file mode 100644 index 0000000..892341d --- /dev/null +++ b/frontend/src/utils/stringUtils.ts @@ -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; +}