🚀WordPress Plugin Boilerplate using modern web techs like TypeScript, SASS, and so on... on top of a local development environment with Docker and predefined GitLab CI for continous integration and deployment!
(see how the query parameter is double encoded (%2520 instead of %20).
I tracked down the problem to packages/utils/lib/factory/ajax/commonUrlBuilder.tsx where the parameters are explicitely encoded at:
// Find undeclared body params (which are not bind above) and add it to GET query
for (const checkParam of Object.keys(params)) {
if (foundParams.indexOf(checkParam) === -1) {
getParams[checkParam] = encodeURIComponent((params as any)[checkParam]);
}
}
And afterward, the call to Url.toString() at return apiUrl.set("query", deepMerge.all([options.restQuery, getParams, query])).toString();will re-encode the parameter (using stringify).
Why are parameters URIencoded explicitely in commonUrlBuilder ?
Am I using the boilerplate code incorrectly there ?
As the template is missing an example of a API call with parameters, I may be using it in an incorrect way.
I created an endpoint in php expecting a query parameter. The Typescript declaration is the foillowing:
And I use it with :
The code does not work as expected as it leads to the queried URL :
(see how the query parameter is double encoded (%2520 instead of %20).
I tracked down the problem to packages/utils/lib/factory/ajax/commonUrlBuilder.tsx where the parameters are explicitely encoded at:
And afterward, the call to
Url.toString()
atreturn apiUrl.set("query", deepMerge.all([options.restQuery, getParams, query])).toString();
will re-encode the parameter (using stringify).Why are parameters URIencoded explicitely in commonUrlBuilder ?
Am I using the boilerplate code incorrectly there ?