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

Commit a600dce

Browse files
author
Alan Shaw
committed
fix: configure tests
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
1 parent 5dbeb30 commit a600dce

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/lib/configure.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22
/* eslint-env browser */
33

4-
const ky = require('ky-universal')
4+
const ky = require('ky-universal').default
55
const { isBrowser, isWebWorker } = require('ipfs-utils/src/env')
66
const { toUri } = require('./multiaddr')
77
const errorHandler = require('./error-handler')
@@ -18,11 +18,6 @@ module.exports = create => config => {
1818
config = { ...config }
1919
}
2020

21-
if (config.protocol || config.host || config.port) {
22-
const port = config.port ? `:${config.port}` : ''
23-
config.apiAddr = `${config.protocol || 'http'}://${config.host || 'localhost'}${port}`
24-
}
25-
2621
config.apiAddr = (config.apiAddr || getDefaultApiAddr(config)).toString()
2722
config.apiAddr = config.apiAddr.startsWith('/') ? toUri(config.apiAddr) : config.apiAddr
2823
config.apiPath = config.apiPath || config['api-path'] || '/api/v0'
@@ -37,7 +32,8 @@ module.exports = create => config => {
3732
hooks: {
3833
afterResponse: [errorHandler]
3934
}
40-
})
35+
}),
36+
...config
4137
})
4238
}
4339

test/lib.configure.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('lib/configure', () => {
1414
it('should accept no config', () => {
1515
configure(config => {
1616
if (isBrowser || isWebWorker) {
17-
expect(config.apiAddr).to.eql(location.origin)
17+
expect(config.apiAddr).to.eql('')
1818
} else {
1919
expect(config.apiAddr).to.eql('http://localhost:5001')
2020
}
@@ -48,7 +48,7 @@ describe('lib/configure', () => {
4848
if (isBrowser || isWebWorker) {
4949
expect(config.apiAddr).to.eql(`https://${location.host}`)
5050
} else {
51-
expect(config.apiAddr).to.eql('https://localhost')
51+
expect(config.apiAddr).to.eql('https://localhost:5001')
5252
}
5353
})(input)
5454
})
@@ -59,7 +59,7 @@ describe('lib/configure', () => {
5959
if (isBrowser || isWebWorker) {
6060
expect(config.apiAddr).to.eql(`http://ipfs.io:${location.port}`)
6161
} else {
62-
expect(config.apiAddr).to.eql('http://ipfs.io')
62+
expect(config.apiAddr).to.eql('http://ipfs.io:5001')
6363
}
6464
})(input)
6565
})

0 commit comments

Comments
 (0)