@ -27,7 +27,7 @@ export default function setupEnsIpfsResolver ({ provider, getCurrentNetwork, get
}
}
// parse ens name
// parse ens name
const urlData = urlUtil . parse ( url )
const urlData = urlUtil . parse ( url )
const { hostname : name , path , search , hash : fragment } = urlData
const { hostname : name , pathname , search , hash : fragment } = urlData
const domainParts = name . split ( '.' )
const domainParts = name . split ( '.' )
const topLevelDomain = domainParts [ domainParts . length - 1 ]
const topLevelDomain = domainParts [ domainParts . length - 1 ]
// if unsupported TLD, abort
// if unsupported TLD, abort
@ -35,17 +35,17 @@ export default function setupEnsIpfsResolver ({ provider, getCurrentNetwork, get
return
return
}
}
// otherwise attempt resolve
// otherwise attempt resolve
attemptResolve ( { tabId , name , path , search , fragment } )
attemptResolve ( { tabId , name , pathname , search , fragment } )
}
}
async function attemptResolve ( { tabId , name , path , search , fragment } ) {
async function attemptResolve ( { tabId , name , pathname , search , fragment } ) {
const ipfsGateway = getIpfsGateway ( )
const ipfsGateway = getIpfsGateway ( )
extension . tabs . update ( tabId , { url : ` loading.html ` } )
extension . tabs . update ( tabId , { url : ` loading.html ` } )
let url = ` https://app.ens.domains/name/ ${ name } `
let url = ` https://app.ens.domains/name/ ${ name } `
try {
try {
const { type , hash } = await resolveEnsToIpfsContentId ( { provider , name } )
const { type , hash } = await resolveEnsToIpfsContentId ( { provider , name } )
if ( type === 'ipfs-ns' || type === 'ipns-ns' ) {
if ( type === 'ipfs-ns' || type === 'ipns-ns' ) {
const resolvedUrl = ` https:// ${ hash } . ${ type . slice ( 0 , 4 ) } . ${ ipfsGateway } ${ path } ${ search || '' } ${ fragment || '' } `
const resolvedUrl = ` https:// ${ hash } . ${ type . slice ( 0 , 4 ) } . ${ ipfsGateway } ${ pathname } ${ search || '' } ${ fragment || '' } `
try {
try {
// check if ipfs gateway has result
// check if ipfs gateway has result
const response = await window . fetch ( resolvedUrl , { method : 'HEAD' } )
const response = await window . fetch ( resolvedUrl , { method : 'HEAD' } )
@ -56,11 +56,11 @@ export default function setupEnsIpfsResolver ({ provider, getCurrentNetwork, get
console . warn ( err )
console . warn ( err )
}
}
} else if ( type === 'swarm-ns' ) {
} else if ( type === 'swarm-ns' ) {
url = ` https://swarm-gateways.net/bzz:/ ${ hash } ${ path } ${ search || '' } ${ fragment || '' } `
url = ` https://swarm-gateways.net/bzz:/ ${ hash } ${ pathname } ${ search || '' } ${ fragment || '' } `
} else if ( type === 'onion' || type === 'onion3' ) {
} else if ( type === 'onion' || type === 'onion3' ) {
url = ` http:// ${ hash } .onion ${ path } ${ search || '' } ${ fragment || '' } `
url = ` http:// ${ hash } .onion ${ pathname } ${ search || '' } ${ fragment || '' } `
} else if ( type === 'zeronet' ) {
} else if ( type === 'zeronet' ) {
url = ` http://127.0.0.1:43110/ ${ hash } ${ path } ${ search || '' } ${ fragment || '' } `
url = ` http://127.0.0.1:43110/ ${ hash } ${ pathname } ${ search || '' } ${ fragment || '' } `
}
}
} catch ( err ) {
} catch ( err ) {
console . warn ( err )
console . warn ( err )