mirror of
https://github.com/umami-software/umami.git
synced 2026-02-21 21:15:35 +01:00
Compare commits
No commits in common. "39c99997ce947af33441c5e03fe4722ff9f61b63" and "503a1f740c0111cc0034228ca6f21809743130f1" have entirely different histories.
39c99997ce
...
503a1f740c
3 changed files with 12 additions and 32 deletions
|
|
@ -2,7 +2,6 @@ import * as detect from '../detect';
|
|||
import { expect } from '@jest/globals';
|
||||
|
||||
const IP = '127.0.0.1';
|
||||
const BAD_IP = '127.127.127.127';
|
||||
|
||||
test('getIpAddress: Custom header', () => {
|
||||
process.env.CLIENT_IP_HEADER = 'x-custom-ip-header';
|
||||
|
|
@ -18,12 +17,6 @@ test('getIpAddress: Standard header', () => {
|
|||
expect(detect.getIpAddress(new Headers({ 'x-forwarded-for': IP }))).toEqual(IP);
|
||||
});
|
||||
|
||||
test('getIpAddress: CloudFlare header is lower priority than standard header', () => {
|
||||
expect(
|
||||
detect.getIpAddress(new Headers({ 'cf-connecting-ip': BAD_IP, 'x-forwarded-for': IP })),
|
||||
).toEqual(IP);
|
||||
});
|
||||
|
||||
test('getIpAddress: No header', () => {
|
||||
expect(detect.getIpAddress(new Headers())).toEqual(null);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -333,21 +333,17 @@ export const BROWSERS = {
|
|||
yandexbrowser: 'Yandex',
|
||||
};
|
||||
|
||||
// The order here is important and influences how IPs are detected by lib/detect.ts
|
||||
// Please do not change the order unless you know exactly what you're doing - read https://developers.cloudflare.com/fundamentals/reference/http-headers/
|
||||
export const IP_ADDRESS_HEADERS = [
|
||||
'x-client-ip',
|
||||
'x-forwarded-for',
|
||||
'cf-connecting-ip', // This should be *after* x-forwarded-for, so that x-forwarded-for is respected if present
|
||||
'cf-connecting-ip',
|
||||
'do-connecting-ip',
|
||||
'fastly-client-ip',
|
||||
'forwarded',
|
||||
'true-client-ip',
|
||||
'x-real-ip',
|
||||
'x-appengine-user-ip',
|
||||
'x-client-ip',
|
||||
'x-cluster-client-ip',
|
||||
'x-forwarded',
|
||||
'forwarded',
|
||||
'x-appengine-user-ip',
|
||||
'x-nf-client-connection-ip',
|
||||
'x-forwarded-for',
|
||||
'x-real-ip',
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -38,18 +38,6 @@
|
|||
|
||||
/* Helper functions */
|
||||
|
||||
const normalize = raw => {
|
||||
if (!raw) return raw;
|
||||
try {
|
||||
const u = new URL(raw, location.href);
|
||||
if (excludeSearch) u.search = '';
|
||||
if (excludeHash) u.hash = '';
|
||||
return u.toString();
|
||||
} catch (e) {
|
||||
return raw;
|
||||
}
|
||||
};
|
||||
|
||||
const getPayload = () => ({
|
||||
website,
|
||||
screen,
|
||||
|
|
@ -73,7 +61,11 @@
|
|||
if (!url) return;
|
||||
|
||||
currentRef = currentUrl;
|
||||
currentUrl = normalize(new URL(url, location.href).toString());
|
||||
currentUrl = new URL(url, location.href);
|
||||
|
||||
if (excludeSearch) currentUrl.search = '';
|
||||
if (excludeHash) currentUrl.hash = '';
|
||||
currentUrl = currentUrl.toString();
|
||||
|
||||
if (currentUrl !== currentRef) {
|
||||
setTimeout(track, delayDuration);
|
||||
|
|
@ -218,9 +210,8 @@
|
|||
};
|
||||
}
|
||||
|
||||
let currentUrl = normalize(href);
|
||||
let currentRef = normalize(referrer.startsWith(origin) ? '' : referrer);
|
||||
|
||||
let currentUrl = href;
|
||||
let currentRef = referrer.startsWith(origin) ? '' : referrer;
|
||||
let initialized = false;
|
||||
let disabled = false;
|
||||
let cache;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue