Skip to content

Commit

Permalink
Implement aliasToPath helper
Browse files Browse the repository at this point in the history
  • Loading branch information
retro committed Aug 5, 2024
1 parent 8ed52e8 commit ae2b2e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/__tests__/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,10 @@ it("can convert path to alias", () => {
"user___user_id",
);
});

it("can convert alias to path", () => {
assert.equal(
semanticLayer.helpers.aliasToPath("user___user_id"),
"user.user_id",
);
});
4 changes: 4 additions & 0 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ export function formatResults<T extends Record<string, unknown>>(
export function pathToAlias(path: string) {
return path.replaceAll(".", "___");
}

export function aliasToPath(alias: string) {
return alias.replaceAll("___", ".");
}

0 comments on commit ae2b2e5

Please sign in to comment.