imagekit-developer / imagekit-javascript

Javascript SDK for using ImageKit.io
https://imagekit.io
77 stars 26 forks source link

URLSearchParams #8

Closed tylercollier closed 4 years ago

tylercollier commented 4 years ago

Would you consider allowing developers to specify the URLSearchParams implementation? The situation I'm running into is with React Native. When I use imagekit.url(...), I get the error not implemented. This is due to a bug in React Native. There is a way to get around it, but this bloats the bundle size, so it'd be better if I could instead include another implementation of URLSearchParams, such as this one. I'm guessing you'd do it like this:

const URLSearchParamsPolyfill = require('url-search-params-polyfill');

var imagekit = new ImageKit({
    publicKey : "your_public_api_key",
    urlEndpoint : "https://ik.imagekit.io/your_imagekit_id",
    authenticationEndpoint : "http://www.yourserver.com/auth",
    URLSearchParams: URLSearchParamsPolyfill,
});  
imagekitio commented 4 years ago

It seems that if we use . append method which is implemented instead of .set then it will work.

Please test the changes in latest version 1.2.1

tylercollier commented 4 years ago

It works, thanks!

rpavlovs commented 3 years ago

Getting the same error on 1.3.7. This time it's .pathname

yarn.lock diff shows that url-polyfill was dropped when updating from 1.2.3