MCPcopy Create free account
hub / github.com/bytebase/bytebase / getNameParentTokens

Function getNameParentTokens

frontend/src/store/modules/v1/common.ts:45–65  ·  view source on GitHub ↗
(
  name: string,
  tokenPrefixes: string[]
)

Source from the content-addressed store, hash-verified

43};
44
45export const getNameParentTokens = (
46 name: string,
47 tokenPrefixes: string[]
48): string[] => {
49 const parts = name.split("/");
50 if (parts.length !== tokenPrefixes.length * 2) {
51 return [];
52 }
53
54 const tokens: string[] = [];
55 for (let i = 0; i < tokenPrefixes.length; i++) {
56 if (parts[i * 2] + "/" !== tokenPrefixes[i]) {
57 return [];
58 }
59 if (parts[i * 2 + 1] === "") {
60 return [];
61 }
62 tokens.push(parts[i * 2 + 1]);
63 }
64 return tokens;
65};
66
67export const getWorkspaceId = (name: string): string => {
68 const tokens = getNameParentTokens(name, [workspaceNamePrefix]);

Callers 15

getWorkspaceIdFunction · 0.85
getEnvironmentIdFunction · 0.85
getUserIdFunction · 0.85
getNumberIdFunction · 0.85
getProjectNameFunction · 0.85
getProjectNamePlanIdFunction · 0.85
getWorksheetIdFunction · 0.85
getInstanceIdFunction · 0.85
getInstanceAndDatabaseIdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected