From b2304b70086eb3896f9ccb8bf37a99a08268854f Mon Sep 17 00:00:00 2001 From: gozzy Date: Sat, 12 Nov 2022 01:12:11 +0000 Subject: [PATCH] improve ipfs detection & update notifications --- pages/index.vue | 28 +--------------------------- plugins/detectIPFS.js | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index 8bd74d7..ecf147d 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -83,31 +83,6 @@ - - - - - - -
@@ -140,8 +115,7 @@ export default { data() { return { activeTab: 0, - isActive: false, - isEthLink: window.location.host === 'tornadocash.eth.link' + isActive: false } }, computed: { diff --git a/plugins/detectIPFS.js b/plugins/detectIPFS.js index d8a9b0e..ae1c466 100644 --- a/plugins/detectIPFS.js +++ b/plugins/detectIPFS.js @@ -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 }