From b00bf8969e44b8dec905e4e1cc6198b29d78bee5 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 10 Nov 2020 00:05:54 +0100 Subject: [PATCH] fix: support API on ipv6 with go-ipfs 0.8+ (#931) This removes unnecessary normalization of ipv6 URLs. --- add-on/src/lib/ipfs-client/external.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/add-on/src/lib/ipfs-client/external.js b/add-on/src/lib/ipfs-client/external.js index 84dc0cdc4..f52d94854 100644 --- a/add-on/src/lib/ipfs-client/external.js +++ b/add-on/src/lib/ipfs-client/external.js @@ -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 }