adobe / aem-headless-client-js

AEM Headless Client for JavaScript
Apache License 2.0
25 stars 12 forks source link

fix: #51 persisted query string parameter encoding #53

Closed cpilsworth closed 1 year ago

cpilsworth commented 1 year ago

Fixes a problem where persisted query string parameters are not being properly encoded

Description

JSON.stringify is used to coerce objects into string parameters. When it's used on a string, the value is quoted adding some additional, unexpected characters to the encoded url.

For example, where the parameter name: test is provided, then it is output in the url as:

Related Issue

49, #51

Motivation and Context

How Has This Been Tested?

Added a unit test that failed with simple key=value parameters by verifying the url passed to fetch. Test passes with small change to the runPersistedQuery function that checks the val type before using JSON.stringify(...)

Screenshots (if appropriate):

Types of changes

Checklist: