forked from Stigmatoz/web-activity-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock-page.ts
More file actions
30 lines (27 loc) · 839 Bytes
/
block-page.ts
File metadata and controls
30 lines (27 loc) · 839 Bytes
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
29
30
export enum BlockParams {
Domain = 'domain',
URL = 'url',
LimitTime = 'summaryTime',
SummaryCounter = 'summaryCounter',
}
export function buildBlockQuery(
domain: string,
url: string,
liimitTime: number,
summaryCounter: number,
) {
return `?domain=${domain}&url=${url}&summaryTime=${liimitTime}&summaryCounter=${summaryCounter}`;
}
export function getValueFromQuery(url: string) {
const urlObj = new URL(url);
const domain = urlObj.searchParams.get(BlockParams.Domain);
const sourceUrl = urlObj.searchParams.get(BlockParams.URL);
const limitTime = Number(urlObj.searchParams.get(BlockParams.LimitTime));
const summaryCounter = Number(urlObj.searchParams.get(BlockParams.SummaryCounter));
return {
domain: domain,
url: sourceUrl,
limitTime: limitTime,
summaryCounter: summaryCounter,
};
}