aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorPhyrexTsai <x01ep23i@hotmail.com>2018-06-29 13:57:41 +0800
committerGitHub <noreply@github.com>2018-06-29 13:57:41 +0800
commit11736e6318182ab5b43430410a46059e5f46ad52 (patch)
tree8e5a036f8f317400f36e01b5e2cafbbd984921dd /app/scripts
parent8a571ece367f089e9cfef45fed925736c5858e82 (diff)
downloadtangerine-wallet-browser-11736e6318182ab5b43430410a46059e5f46ad52.tar
tangerine-wallet-browser-11736e6318182ab5b43430410a46059e5f46ad52.tar.gz
tangerine-wallet-browser-11736e6318182ab5b43430410a46059e5f46ad52.tar.bz2
tangerine-wallet-browser-11736e6318182ab5b43430410a46059e5f46ad52.tar.lz
tangerine-wallet-browser-11736e6318182ab5b43430410a46059e5f46ad52.tar.xz
tangerine-wallet-browser-11736e6318182ab5b43430410a46059e5f46ad52.tar.zst
tangerine-wallet-browser-11736e6318182ab5b43430410a46059e5f46ad52.zip
Update to support pathnames on IPFS hash
As @Georgi87 mentioned about pathnames on the domain like `http://phyrextsai.eth/home` will pass to IPFS hash and append `/home` on redirection url. You can try the example below: http://phyrextsai.eth/index.html http://phyrextsai.eth/images/phyrex.jpg
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/lib/ipfsContent.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/scripts/lib/ipfsContent.js b/app/scripts/lib/ipfsContent.js
index 46131b266..2ddbe5558 100644
--- a/app/scripts/lib/ipfsContent.js
+++ b/app/scripts/lib/ipfsContent.js
@@ -3,8 +3,12 @@ const resolver = require('./resolver.js')
module.exports = function (provider) {
extension.webRequest.onBeforeRequest.addListener(details => {
- const name = details.url.substring(7, details.url.length - 1)
+ const urlhttpreplace = details.url.replace(/\w+?:\/\//, "")
+ const url = urlhttpreplace.replace(/[\\\/].*/g, "")
+ let domainhtml = urlhttpreplace.match(/[\\\/].*/g)
let clearTime = null
+ let name = url.replace(/\/$/g, "")
+ if (domainhtml === null) domainhtml = [""]
extension.tabs.getSelected(null, tab => {
extension.tabs.update(tab.id, { url: 'loading.html' })
@@ -14,13 +18,13 @@ module.exports = function (provider) {
resolver.resolve(name, provider).then(ipfsHash => {
clearTimeout(clearTime)
- let url = 'https://ipfs.infura.io/ipfs/' + ipfsHash
+ let url = 'https://ipfs.infura.io/ipfs/' + ipfsHash + domainhtml[0]
return fetch(url, { method: 'HEAD' }).then(response => response.status).then(statusCode => {
if (statusCode !== 200) return extension.tabs.update(tab.id, { url: '404.html' })
extension.tabs.update(tab.id, { url: url })
})
.catch(err => {
- url = 'https://ipfs.infura.io/ipfs/' + ipfsHash
+ url = 'https://ipfs.infura.io/ipfs/' + ipfsHash + domainhtml[0]
extension.tabs.update(tab.id, {url: url})
return err
})
@@ -32,5 +36,5 @@ module.exports = function (provider) {
})
})
return { cancel: true }
- }, {urls: ['*://*.eth/']})
+ }, {urls: ['*://*.eth/', '*://*.eth/*']})
}