From 9d186707ccfa7cf2d2332c01308c339586d44bd1 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Fri, 25 Jan 2019 17:00:02 +0000 Subject: [PATCH 1/3] feat: return protocol from getEndpointConfig The protocol is used to construct the request, and it's useful to be able to check it has been set correctly, so we add it here to he the util.getEndpointConfig() return value. License: MIT Signed-off-by: Oli Evans --- README.md | 2 +- src/util/get-endpoint-config.js | 3 ++- test/util.spec.js | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) 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..e879064f5 100644 --- a/src/util/get-endpoint-config.js +++ b/src/util/get-endpoint-config.js @@ -3,6 +3,7 @@ module.exports = (config) => { return () => ({ host: config.host, - port: config.port + port: config.port, + protocol: config.protocol }) } diff --git a/test/util.spec.js b/test/util.spec.js index ff0b83c81..031eeaad8 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -35,10 +35,12 @@ 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') + // changes per test run so we just assert it exists. expect(endpoint).to.have.property('port') }) }) From 17b4af4f62fb01b6b82d7e39406877ec3624ee5a Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Mon, 28 Jan 2019 11:16:04 +0000 Subject: [PATCH 2/3] feat: add api-path to getEndpointConfig License: MIT Signed-off-by: Oli Evans --- src/util/get-endpoint-config.js | 3 ++- test/util.spec.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/get-endpoint-config.js b/src/util/get-endpoint-config.js index e879064f5..a4f0c80e1 100644 --- a/src/util/get-endpoint-config.js +++ b/src/util/get-endpoint-config.js @@ -4,6 +4,7 @@ module.exports = (config) => { return () => ({ host: config.host, port: config.port, - protocol: config.protocol + protocol: config.protocol, + 'api-path': config['api-path'] }) } diff --git a/test/util.spec.js b/test/util.spec.js index 031eeaad8..3216d0534 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -40,8 +40,10 @@ describe('.util', () => { 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') + }) }) From 6bfac71c333fa5b150d75a50c3d19f69d8aaf80c Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Mon, 28 Jan 2019 12:46:28 +0000 Subject: [PATCH 3/3] chore: appease linter --- test/util.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/util.spec.js b/test/util.spec.js index 3216d0534..002a7777f 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -43,7 +43,6 @@ describe('.util', () => { expect(endpoint['api-path']).to.equal('/api/v0/') // changes per test run so we just assert it exists. expect(endpoint).to.have.property('port') - }) })