Filter domain from referrers.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import escape from 'escape-string-regexp';
|
||||
import { BROWSERS, ISO_COUNTRIES, DEVICES } from './constants';
|
||||
|
||||
export const browserFilter = data =>
|
||||
@@ -5,8 +6,12 @@ export const browserFilter = data =>
|
||||
|
||||
export const urlFilter = data => data.filter(({ x }) => x !== '' && !x.startsWith('#'));
|
||||
|
||||
export const refFilter = data =>
|
||||
data.filter(({ x }) => x !== '' && !x.startsWith('/') && !x.startsWith('#'));
|
||||
export const refFilter = domain => data => {
|
||||
const regex = new RegExp(escape(domain));
|
||||
return data.filter(
|
||||
({ x }) => x !== '' && !x.startsWith('/') && !x.startsWith('#') && !regex.test(x),
|
||||
);
|
||||
};
|
||||
|
||||
export const deviceFilter = data =>
|
||||
data.map(({ x, ...props }) => ({ x: DEVICES[x] || x, ...props }));
|
||||
|
||||
Reference in New Issue
Block a user