1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-23 00:16:25 +01:00
unleash.unleash/frontend/src/component/onboarding/parseToken.ts
2024-09-03 11:28:16 +02:00

21 lines
477 B
TypeScript

export const parseToken = (
token?: string,
): { project: string; environment: string; secret: string } | null => {
if (!token) return null;
const [project, rest] = token.split(':', 2);
if (!rest) return null;
const [environment, secret, ...extra] = rest.split('.');
if (project && environment && secret && extra.length === 0) {
return {
project,
environment,
secret,
};
}
return null;
};