aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/ens-ipfs/setup.js
diff options
context:
space:
mode:
authorThomas Huang <tmashuang@users.noreply.github.com>2019-06-05 05:55:56 +0800
committerGitHub <noreply@github.com>2019-06-05 05:55:56 +0800
commitbe911711942914e7f6df535afff1a3ee87e23b6f (patch)
treebbd890e0a6a1bd72d2560e734ce66ed42a294722 /app/scripts/lib/ens-ipfs/setup.js
parent3d7bdd6ecb5e8e17cb8ccf83f56ad389971332c1 (diff)
parent28e030a11d75df81e16f3ebf726bfc59fcee679e (diff)
downloadtangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar
tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar.gz
tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar.bz2
tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar.lz
tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar.xz
tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar.zst
tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.zip
Merge pull request #6683 from MetaMask/develop
Merge dev to master
Diffstat (limited to 'app/scripts/lib/ens-ipfs/setup.js')
-rw-r--r--app/scripts/lib/ens-ipfs/setup.js30
1 files changed, 14 insertions, 16 deletions
diff --git a/app/scripts/lib/ens-ipfs/setup.js b/app/scripts/lib/ens-ipfs/setup.js
index df756d0f7..82679db5d 100644
--- a/app/scripts/lib/ens-ipfs/setup.js
+++ b/app/scripts/lib/ens-ipfs/setup.js
@@ -37,27 +37,25 @@ function setupEnsIpfsResolver ({ provider }) {
async function attemptResolve ({ tabId, name, path, search }) {
extension.tabs.update(tabId, { url: `loading.html` })
+ let url = `https://manager.ens.domains/name/${name}`
try {
- const ipfsContentId = await resolveEnsToIpfsContentId({ provider, name })
- const url = `https://gateway.ipfs.io/ipfs/${ipfsContentId}${path}${search || ''}`
- try {
- // check if ipfs gateway has result
- const response = await fetch(url, { method: 'HEAD' })
- // if failure, redirect to 404 page
- if (response.status !== 200) {
- extension.tabs.update(tabId, { url: '404.html' })
- return
+ const {type, hash} = await resolveEnsToIpfsContentId({ provider, name })
+ if (type === 'ipfs-ns') {
+ const resolvedUrl = `https://gateway.ipfs.io/ipfs/${hash}${path}${search || ''}`
+ try {
+ // check if ipfs gateway has result
+ const response = await fetch(resolvedUrl, { method: 'HEAD' })
+ if (response.status === 200) url = resolvedUrl
+ } catch (err) {
+ console.warn(err)
}
- // otherwise redirect to the correct page
- extension.tabs.update(tabId, { url })
- } catch (err) {
- console.warn(err)
- // if HEAD fetch failed, redirect so user can see relevant error page
- extension.tabs.update(tabId, { url })
+ } else if (type === 'swarm-ns') {
+ url = `https://swarm-gateways.net/bzz:/${hash}${path}${search || ''}`
}
} catch (err) {
console.warn(err)
- extension.tabs.update(tabId, { url: `error.html?name=${name}` })
+ } finally {
+ extension.tabs.update(tabId, { url })
}
}
}