geotiffjs / geotiff.js

geotiff.js is a small library to parse TIFF files for visualization or analysis. It is written in pure JavaScript, and is usable in both the browser and node.js applications.
https://geotiffjs.github.io/
MIT License
878 stars 183 forks source link

Fix undeclared `http` variable for Node.js #211

Closed aloisklink closed 3 years ago

aloisklink commented 3 years ago

In commit 3f129bbcc1025be786da34216ba40c05ad495eea, where the http files were restructured, it looks like the import http was not added to the new file.

This causes a 'ReferenceError: http is not defined' when trying to get a geotiff.

I've removed the if (http.get) condition, since normally, it should never fail. If we are running on a browser, fetch() should exist for any new browser, otherwise XMLHttpRequest would exist, so the function would return early and never reach if (http.get).

Therefore, we must be running on Node.JS, where the http library exists.

constantinius commented 3 years ago

Ah, shoot, good catch, thanks!