QuantumMechanics / NEM-sdk

NEM Developer Kit for Node.js and the browser
MIT License
137 stars 82 forks source link

nem.utils.helper.formatEndpoint should not add ':' when port is empty #47

Open Alexhuszagh opened 6 years ago

Alexhuszagh commented 6 years ago

I'm using a proxy service for a demo React application, which proxies a node to a path relative to the application, say.

For example, say my node is at http://localhost:7890, and my proxy redirects this to http://localhost:3000/api/node, using the NEM-SDK's formatEndpoint converts this to http://localhost:3000/api/node/:, which is an invalid IP address.

The fix is trivial: simply check if the port is empty before adding the semicolon. It really would help for applications making use of the NEM SDK, particularly for those that require proxies to avoid CORs (Cross-Origin Requests).