Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

feat: return protocol from getEndpointConfig #935

Merged
merged 3 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/util/get-endpoint-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
})
}
8 changes: 6 additions & 2 deletions test/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ 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')

})
})

Expand Down