cosmicjs / cosmic-sdk-js

The official JavaScript SDK for Cosmic. Use it to power content server-side, in the browser, and in native apps.
https://www.npmjs.com/package/@cosmicjs/sdk
MIT License
14 stars 2 forks source link

This should be encodeURIComponent #25

Closed facingmonday closed 1 year ago

facingmonday commented 1 year ago

An ampersand in the query string was breaking the request.

For example

cosmic.objects.find({
  type: 'type',
  title: 'Something & SomethingElse'
})
    .props([
      'id',
      'title',
    ])
    .limit(1);

Will return: 'Query must be valid JSON string.'

encodeURI needs changed to encodeURIComponent

https://github.com/cosmicjs/cosmic-sdk-js/blob/df94d669b6ae2267fab7478955f0c725ff8c8013/src/clients/bucket/objects/index.ts#L28

tonyspiro commented 1 year ago

Thanks for the report. We are looking into this.

tonyspiro commented 1 year ago

@facingmonday this is now fixed in v1.0.10. Please run npm i @cosmicjs/sdk@latest, test it, and let me know if you run into any issue. I'll go ahead and close this issue.