forked from deriv-com/p2p
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorage.ts
22 lines (19 loc) · 846 Bytes
/
storage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Cookies from 'js-cookie';
export const removeCookies = (...cookieNames: string[]) => {
const currentDomain = document.domain ?? '';
const domains = [`.${currentDomain.split('.').slice(-2).join('.')}`, `.${currentDomain}`];
let parentPath = window.location.pathname.split('/', 2)[1];
if (parentPath !== '') {
parentPath = `/${parentPath}`;
}
cookieNames.forEach(c => {
Cookies.remove(c, { domain: domains[0], path: '/' });
Cookies.remove(c, { domain: domains[1], path: '/' });
Cookies.remove(c);
if (new RegExp(c).test(document.cookie) && parentPath) {
Cookies.remove(c, { domain: domains[0], path: parentPath });
Cookies.remove(c, { domain: domains[1], path: parentPath });
Cookies.remove(c, { path: parentPath });
}
});
};