Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

willdcard support

Maksim Mrugc224658d7718
diff --git a/apps/production/src/analytics/analytics.service.ts b/apps/production/src/analytics/analytics.service.ts
index 89e9ed1d2..30465bd40 100644
--- a/apps/production/src/analytics/analytics.service.ts
+++ b/apps/production/src/analytics/analytics.service.ts
@@ -12,6 +12,9 @@ import * as _now from 'lodash/now'
import * as _values from 'lodash/values'
import * as _round from 'lodash/round'
import * as _filter from 'lodash/filter'
+import * as _every from 'lodash/every'
+import * as _tail from 'lodash/tail'
+import * as _trim from 'lodash/trim'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
import * as dayjsTimezone from 'dayjs/plugin/timezone'
@@ -241,6 +244,29 @@ export class AnalyticsService {
"This origin is prohibited by the project's origins policy",
)
}
+
+ if (
+ _some(origins, (item: string) => {
+ const originParts = _map(_split(item, '.'), part => _trim(part))
+ const hostnameParts = _map(_split(hostname, '.'), part =>
+ _trim(part),
+ )
+
+ if (originParts.length === hostnameParts.length) {
+ return _every(
+ originParts,
+ (part: string, index: number) =>
+ part === '*' || part === hostnameParts[index],
+ )
+ }
+
+ return false
+ })
+ ) {
+ throw new BadRequestException(
+ "This origin is prohibited by the project's origins policy",
+ )
+ }
}
}
}