Skip to content

Commit

Permalink
fix: support API on ipv6 with go-ipfs 0.8+ (#931)
Browse files Browse the repository at this point in the history
This removes unnecessary normalization of ipv6 URLs.
  • Loading branch information
lidel authored Nov 9, 2020
1 parent bbb2945 commit b00bf89
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions add-on/src/lib/ipfs-client/external.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ const debug = require('debug')
const log = debug('ipfs-companion:client:external')
log.error = debug('ipfs-companion:client:external:error')

const IpfsApi = require('ipfs-http-client')
const httpClient = require('ipfs-http-client')

exports.init = async function (opts) {
log(`init with IPFS API at ${opts.apiURLString}`)

const url = opts.apiURL
const protocol = url.protocol.substr(0, url.protocol.length - 1) // http: -> http
const host = url.hostname.replace(/[[\]]+/g, '') // temporary fix for ipv6: https://github.com/ipfs-shipyard/ipfs-companion/issues/668
const api = IpfsApi({ host, port: url.port, protocol })
const clientConfig = opts.apiURLString
// https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client#importing-the-module-and-usage
const api = httpClient(clientConfig)
return api
}

Expand Down

0 comments on commit b00bf89

Please sign in to comment.