d3 / d3-request

A convenient alternative to XMLHttpRequest.
BSD 3-Clause "New" or "Revised" License
110 stars 54 forks source link

Relative URLs falling back to "localhost" and no port instead of the window.location.host/port in v1.0.6 -- Browserify build #28

Closed joeldouglass closed 7 years ago

joeldouglass commented 7 years ago

As of 1.0.6, requesting a relative URL no longer seems to work correctly. At least this is the case when building with Browserify...

For example, if I'm hosting a dev site at: http://mydevsite:8888 and try something like d3.csv('/data.csv') a request will be made to http://localhost/data.csv instead of http://mydevsite:8888/data.csv'.

Steps to reproduce:

1) npm install -g browserify 2) In a clean folder, create an index.html file:

<html>
  <head>
    <script src="/generated.js"></script>
  </head>
  <body></body>
</html>

3) Create an index.js file:

const {csv} = require('d3-request');
csv('/test.csv', console.log);

4) Create a sample test.csv file 5) npm install d3-request@1.0.5 6) browserify index.js -o generated.js 7) python -m SimpleHTTPServer 8888 8) Open up in a browser (use http://127.0.0.1:8888) and verify that the csv file is properly requested at http://127.0.0.1:8888/test.csv

9) Next: npm install d3-request@1.0.6 and repeat steps 6-8 10) See that the the requested path is: http://localhost/test.csv

mbostock commented 7 years ago

Duplicate of #24.

bhagyas commented 5 years ago

This seems to be an issue with browsers, I have reported this at Chrome.