improve ipfs detection & update notifications

This commit is contained in:
gozzy 2022-11-12 01:12:11 +00:00
parent 61c2865c46
commit b2304b7008
2 changed files with 20 additions and 31 deletions

@ -83,31 +83,6 @@
</i18n>
</b-notification>
<b-notification
v-if="isEthLink"
:active="isActiveNotification.ethLink"
class="main-notification"
type="is-warning"
icon-pack="icon"
has-icon
:aria-close-label="$t('closeNotification')"
@close="disableNotification({ key: 'ethLink' })"
>
<i18n path="ethLinkBanner.notification">
<template v-slot:issue>
<a
href="https://discuss.ens.domains/t/eth-link-expiry/13899"
target="_blank"
rel="noopener noreferrer"
>{{ $t('ethLinkBanner.issue') }}</a
>
</template>
<template v-slot:alternative>
<a href="https://tornado.cash/">{{ $t('ethLinkBanner.alternative') }}</a>
</template>
</i18n>
</b-notification>
<div class="columns">
<div class="column is-half">
<b-tabs v-model="activeTab" class="is-tornado" :animated="false" @input="tabChanged">
@ -140,8 +115,7 @@ export default {
data() {
return {
activeTab: 0,
isActive: false,
isEthLink: window.location.host === 'tornadocash.eth.link'
isActive: false
}
},
computed: {

@ -3,13 +3,28 @@ export default ({ store, isHMR, app }, inject) => {
inject('isLoadedFromIPFS', main)
}
function main() {
const whiteListedDomains = ['localhost:3000', 'tornadocash.eth.link', 'tornadocash.eth.limo']
const whiteListedDomains = [
'tornadocash.3th.li',
'tornadocash.3th.ws',
'tornadocash.eth.link',
'tornadocash.eth.limo',
'tornadocashcommunity.3th.li',
'tornadocashcommunity.3th.ws',
'tornadocashcommunity.eth.link',
'tornadocashcommunity.eth.limo'
]
const NETLIFY_REGEXP = /deploy-preview-(\d+)--tornadocash\.netlify\.app/
const IPFS_GATEWAY_REGEXP = /.ipfs./
const IPFS_LOCAL_REGEXP = /.ipfs.localhost:/
const IPFS_SOP_GATEWAY_REGEXP = /\/ipfs\//
if (NETLIFY_REGEXP.test(window.location.host)) {
if (IPFS_LOCAL_REGEXP.test(window.location.host)) {
return false
} else if (!whiteListedDomains.includes(window.location.host)) {
} else if (
IPFS_GATEWAY_REGEXP.test(window.location.host) ||
IPFS_SOP_GATEWAY_REGEXP.test(window.location.host) ||
whiteListedDomains.includes(window.location.host)
) {
console.warn('The page has been loaded from ipfs.io. LocalStorage is disabled')
return true
}