[gatsby-source-filesystem] support remote urls with GET query #2985
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently gatsby would fail to build (at least on windows) when using
createRemoteFileNode
(imported fromgatsby-source-filesystem
) with URL that contains GET query (f.e. some images from facebook graph api - https://external.xx.fbcdn.net/safe_image.php?d=AQAcMebX6qD2g7NL&url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FcwGbD7OgvM8uI%2Fgiphy.gif&_nc_hash=AQB7E1MjiB7Vhee6 ).It's because
path.parse(url).ext
(used to build bothtmpFilename
and finalfilename
) would return extension with GET query attached (using my example.php?d=[...]
) and question mark is illegal character in windows filename (pretty sure it can cause troubles on linux too).After fixing that, there is issue that
gatsby-source-filesystem
set MIME type from extension and.php
obviously won't get correct image type and thus will not allow to use image transformer plugins. So in case of not detecting type from extension (checking for generalapplication/octet-stream
as permime
module documentation - https://github.com/broofa/node-mime/tree/v1.4.0#mimelookuppath) this will try to figure out MIME type / extension withfile-type
package.This is Request for comments! for now. It wasn't tested in this form (I duplicated
createRemoteFileNode
function in my source plugin and got this to work)