mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-23 00:16:25 +01:00
21 lines
477 B
TypeScript
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;
|
|
};
|