mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Domain validation. Filter domain from referrers.
This commit is contained in:
parent
a9765c7ea7
commit
5a4cde854a
13 changed files with 51 additions and 23 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { getRankings } from 'lib/queries';
|
||||
import { ok, badRequest } from 'lib/response';
|
||||
import { DOMAIN_REGEX } from '../../../../lib/constants';
|
||||
|
||||
const sessionColumns = ['browser', 'os', 'device', 'country'];
|
||||
const pageviewColumns = ['url', 'referrer'];
|
||||
|
|
@ -24,12 +25,18 @@ function getColumn(type) {
|
|||
}
|
||||
|
||||
export default async (req, res) => {
|
||||
const { id, type, start_at, end_at } = req.query;
|
||||
const { id, type, start_at, end_at, domain } = req.query;
|
||||
const websiteId = +id;
|
||||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
|
||||
if (type !== 'event' && !sessionColumns.includes(type) && !pageviewColumns.includes(type)) {
|
||||
if (
|
||||
type !== 'event' &&
|
||||
!sessionColumns.includes(type) &&
|
||||
!pageviewColumns.includes(type) &&
|
||||
domain &&
|
||||
DOMAIN_REGEX.test(domain)
|
||||
) {
|
||||
return badRequest(res);
|
||||
}
|
||||
|
||||
|
|
@ -39,6 +46,7 @@ export default async (req, res) => {
|
|||
endDate,
|
||||
getColumn(type),
|
||||
getTable(type),
|
||||
domain,
|
||||
);
|
||||
|
||||
return ok(res, rankings);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue