Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dx | 2269 #303

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/core/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,21 @@ export default class Stack {
*/

sync(params, fetchOptions) {
if (params && typeof params !== "object") {
throw new Error("Invalid parameters: params must be an object.");
}
this._query = {};
this._query = Utils.mergeDeep(this._query, params);

if (params) {
for (const key in params) {
if (params.hasOwnProperty(key)) {
if (typeof params[key] !== "string" && typeof params[key] !== "number") {
throw new Error(`Invalid parameter value for key "${key}": must be a string or number.`);
}
this._query[key] = params[key];
}
}
}
this.requestParams = {
method: 'POST',
headers: Utils.mergeDeep({}, this.headers),
Expand Down Expand Up @@ -630,7 +643,9 @@ export default class Stack {
if (url && typeof url === "string" && typeof params === "object" && params.length === undefined) {
let queryParams = [];
for (const operation in params) {
queryParams.push(operation + '=' + params[operation]);
const encodedKey = encodeURIComponent(operation);
const encodedValue = encodeURIComponent(params[operation]);
queryParams.push(encodedKey + '=' + encodedValue);
}
url += (url.indexOf("?") <= -1) ? "?" + queryParams.join('&') : "&" + queryParams.join('&');
}
Expand Down
Loading