Try/catch URL parsing of referrer (#4511)

zio/stable
Samuel Newman 2024-06-13 23:06:22 +01:00 committed by GitHub
parent d9066a6beb
commit bdeac28d74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 6 deletions

View File

@ -43,12 +43,19 @@ if (isWeb && typeof window !== 'undefined') {
refUrl = decodeURIComponent(params.get('ref_url') ?? '') refUrl = decodeURIComponent(params.get('ref_url') ?? '')
} }
if (isWeb && typeof document !== 'undefined' && document != null) { if (
const url = new URL(document.referrer) isWeb &&
if (url.hostname !== 'bsky.app') { typeof document !== 'undefined' &&
referrer = document.referrer document != null &&
referrerHostname = url.hostname document.referrer
} ) {
try {
const url = new URL(document.referrer)
if (url.hostname !== 'bsky.app') {
referrer = document.referrer
referrerHostname = url.hostname
}
} catch {}
} }
export type {LogEvents} export type {LogEvents}