This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change 11'use strict'
22/* eslint-env browser */
33
4- const ky = require ( 'ky-universal' )
4+ const ky = require ( 'ky-universal' ) . default
55const { isBrowser, isWebWorker } = require ( 'ipfs-utils/src/env' )
66const { toUri } = require ( './multiaddr' )
77const 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
Original file line number Diff line number Diff 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 } )
You can’t perform that action at this time.
0 commit comments