diff --git a/README.md b/README.md index 9c62638e0..4bcc34255 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,7 @@ Complete documentation for these methods is coming with: https://github.com/ipfs > `ipfs.util.getEndpointConfig()` -This returns an object containing the `host` and the `port` +This returns an object containing the `host`, `port` and `protocol` ##### Get libp2p crypto primitives diff --git a/src/util/get-endpoint-config.js b/src/util/get-endpoint-config.js index 7598239ee..a4f0c80e1 100644 --- a/src/util/get-endpoint-config.js +++ b/src/util/get-endpoint-config.js @@ -3,6 +3,8 @@ module.exports = (config) => { return () => ({ host: config.host, - port: config.port + port: config.port, + protocol: config.protocol, + 'api-path': config['api-path'] }) } diff --git a/test/util.spec.js b/test/util.spec.js index ff0b83c81..002a7777f 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -35,10 +35,13 @@ describe('.util', () => { }) describe('.getEndpointConfig', () => { - it('should return the endpoint configured host and port', function () { + it('should return the endpoint configuration', function () { const endpoint = ipfs.util.getEndpointConfig() - expect(endpoint).to.have.property('host') + expect(endpoint.host).to.equal('127.0.0.1') + expect(endpoint.protocol).to.equal('http') + expect(endpoint['api-path']).to.equal('/api/v0/') + // changes per test run so we just assert it exists. expect(endpoint).to.have.property('port') }) })