Don't use referrer if it's our domain

This commit is contained in:
artur
2024-02-13 08:19:42 +03:00
parent 45c39ca904
commit e9b290db30
3 changed files with 16 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
import { nip19 } from 'nostr-tools'
import { ACTIONS, ACTION_TYPE, NIP46_RELAYS } from '../consts'
import { ACTIONS, ACTION_TYPE, DOMAIN, NIP46_RELAYS } from '../consts'
import { DbPending, DbPerm } from '@/modules/db'
import { MetaEvent } from '@/types/meta-event'
@@ -105,6 +105,17 @@ export const getDomain = (url: string) => {
}
}
export const getReferrerAppUrl = () => {
console.log('referrer', window.document.referrer)
if (!window.document.referrer) return ''
try {
const u = new URL(window.document.referrer.toLocaleLowerCase())
if (u.hostname != DOMAIN && !u.hostname.endsWith("."+DOMAIN))
return u.origin
} catch {}
return ''
}
export const getAppIconTitle = (name: string | undefined, appNpub: string) => {
return name ? name[0].toLocaleUpperCase() : appNpub.substring(4, 7)
}