Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process url fragment #7604

Merged
merged 1 commit into from
Dec 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app/scripts/lib/ens-ipfs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ function setupEnsIpfsResolver ({ provider }) {
}
// parse ens name
const urlData = urlUtil.parse(url)
const { hostname: name, path, search } = urlData
const { hostname: name, path, search, hash: fragment } = urlData
const domainParts = name.split('.')
const topLevelDomain = domainParts[domainParts.length - 1]
// if unsupported TLD, abort
if (!supportedTopLevelDomains.includes(topLevelDomain)) {
return
}
// otherwise attempt resolve
attemptResolve({ tabId, name, path, search })
attemptResolve({ tabId, name, path, search, fragment })
}

async function attemptResolve ({ tabId, name, path, search }) {
async function attemptResolve ({ tabId, name, path, search, fragment }) {
extension.tabs.update(tabId, { url: `loading.html` })
let url = `https://manager.ens.domains/name/${name}`
let url = `https://app.ens.domains/name/${name}`
try {
const {type, hash} = await resolveEnsToIpfsContentId({ provider, name })
if (type === 'ipfs-ns') {
const resolvedUrl = `https://gateway.ipfs.io/ipfs/${hash}${path}${search || ''}`
const resolvedUrl = `https://gateway.ipfs.io/ipfs/${hash}${path}${search || ''}${fragment || ''}`
try {
// check if ipfs gateway has result
const response = await fetch(resolvedUrl, { method: 'HEAD' })
Expand All @@ -56,11 +56,11 @@ function setupEnsIpfsResolver ({ provider }) {
console.warn(err)
}
} else if (type === 'swarm-ns') {
url = `https://swarm-gateways.net/bzz:/${hash}${path}${search || ''}`
url = `https://swarm-gateways.net/bzz:/${hash}${path}${search || ''}${fragment || ''}`
} else if (type === 'onion' || type === 'onion3') {
url = `http://${hash}.onion${path}${search || ''}`
url = `http://${hash}.onion${path}${search || ''}${fragment || ''}`
} else if (type === 'zeronet') {
url = `http://127.0.0.1:43110/${hash}${path}${search || ''}`
url = `http://127.0.0.1:43110/${hash}${path}${search || ''}${fragment || ''}`
}
} catch (err) {
console.warn(err)
Expand Down