HTTP client factory: Invalid URL #3331
Description
- Version:
js-ipfs version: 0.49.1-84cfa553ffc717d5d8bf94fdf6a306f182c9aee4
interface-ipfs-core version: ^0.139.1
ipfs-http-client version: ^46.0.1
Repo version: 8
System version: x64/darwin
Node.js version: v14.7.0
Commit: 84cfa55
- Platform:
MacOS Catalina 10.15.6
Darwin acostalima 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64
React Native v0.63.2 (tracking RN support at #2813)
- Subsystem:
HTTP client
Severity:
High (?)
Description:
Call the HTTP client factory with a valid URL to create a new client. The factory throws with TypeError
(Invalid URL).
Steps to reproduce the error:
import createHttpClient from 'ipfs-http-client';
createHttpClient({ url: 'http://localhost:5002' }); // throws TypeError 'Invalid URL'
I've tracked down the issue to:
where
options.url
is undefined
.
In the client's constructor, input is being normalized twice:
where opts.url
is already a URL
object from the first pass. URL
s are not being handled by the normalization logic, so options.url
ends up being undefined
.
On one hand, this issue does not appear to be related to React Native. On the other, it's kind of odd because the HTTP client factory does now work like this. 🤔
Am I missing something?
I'll happily open a PR to address this.