-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
tenantOptions.ts
28 lines (27 loc) · 1002 Bytes
/
tenantOptions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2022 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
export const selectTenantsFromCookies = (): string[] => {
const sessionCookieStr = document.cookie
.split(";")
.filter(row => row.trim().startsWith("session="))[0];
return sessionCookieStr
? sessionCookieStr
.replace(/["]/g, "")
.replace("session=", "")
.split(/[,&]/g)
.filter((_, idx) => idx % 2 == 1)
: [];
};
export const selectCurrentTenantFromCookies = (): string | null => {
const tenantCookieStr = document.cookie
.split(";")
.filter(row => row.trim().startsWith("tenant="))[0];
return tenantCookieStr ? tenantCookieStr.replace("tenant=", "") : null;
};