diff options
author | pldespaigne <pl.despaigne@gmail.com> | 2019-05-05 00:57:19 +0800 |
---|---|---|
committer | pldespaigne <pl.despaigne@gmail.com> | 2019-05-05 00:57:19 +0800 |
commit | 2d58cfc7a0768a5d635a12811ed2632b640eca24 (patch) | |
tree | d9c9d83a3693102d3e6ace0c4ab3d822765147f9 /app/scripts | |
parent | 987e58d103ad84757d3a96949db96e7edf3c1a54 (diff) | |
download | tangerine-wallet-browser-2d58cfc7a0768a5d635a12811ed2632b640eca24.tar tangerine-wallet-browser-2d58cfc7a0768a5d635a12811ed2632b640eca24.tar.gz tangerine-wallet-browser-2d58cfc7a0768a5d635a12811ed2632b640eca24.tar.bz2 tangerine-wallet-browser-2d58cfc7a0768a5d635a12811ed2632b640eca24.tar.lz tangerine-wallet-browser-2d58cfc7a0768a5d635a12811ed2632b640eca24.tar.xz tangerine-wallet-browser-2d58cfc7a0768a5d635a12811ed2632b640eca24.tar.zst tangerine-wallet-browser-2d58cfc7a0768a5d635a12811ed2632b640eca24.zip |
refactor & change html pages
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/lib/ens-ipfs/setup.js | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/app/scripts/lib/ens-ipfs/setup.js b/app/scripts/lib/ens-ipfs/setup.js index 43194afbd..82679db5d 100644 --- a/app/scripts/lib/ens-ipfs/setup.js +++ b/app/scripts/lib/ens-ipfs/setup.js @@ -37,33 +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 { - let url = '400.html' const {type, hash} = await resolveEnsToIpfsContentId({ provider, name }) if (type === 'ipfs-ns') { - url = `https://gateway.ipfs.io/ipfs/${hash}${path}${search || ''}` + const resolvedUrl = `https://gateway.ipfs.io/ipfs/${hash}${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 - } - // otherwise redirect to the correct page - extension.tabs.update(tabId, { url }) + const response = await fetch(resolvedUrl, { method: 'HEAD' }) + if (response.status === 200) url = resolvedUrl } 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 || ''}` } - extension.tabs.update(tabId, { url }) } catch (err) { console.warn(err) - extension.tabs.update(tabId, { url: `error.html?name=${name}` }) + } finally { + extension.tabs.update(tabId, { url }) } } } |