Bug Report
Description
The buildUrlParams function in core/src/core-plugins.ts has two bugs:
- Array parameters produce double ampersands (
&&) in the output
- Uses deprecated
substr() method
Root Cause
Bug 1 - Missing assignment (line 336):
value.forEach((str) => {
encodedValue = shouldEncode ? encodeURIComponent(str) : str;
item += `${key}=${encodedValue}&`;
});
// last character will always be "&" so slice it off
item.slice(0, -1); // ❌ Result not assigned!
Bug 2 - Deprecated method (line 346):
return output.substr(1); // ❌ substr is deprecated
Expected Behavior
buildUrlParams({ tags: ['javascript', 'typescript'], key: 'value' })
// Should return: "tags=javascript&tags=typescript&key=value"
Actual Behavior
buildUrlParams({ tags: ['javascript', 'typescript'], key: 'value' })
// Returns: "tags=javascript&tags=typescript&&key=value" // Note the &&
Proposed Fix
Fix 1 - Assign the slice result:
item = item.slice(0, -1);
Fix 2 - Replace deprecated substr:
return output.substring(1);
Impact
- Severity: Medium (malformed URL parameters)
- Affected: HTTP plugin when using array parameters
- Breaking: No
Additional Context
I have a PR ready with both fixes and test cases.
Bug Report
Description
The
buildUrlParamsfunction incore/src/core-plugins.tshas two bugs:&&) in the outputsubstr()methodRoot Cause
Bug 1 - Missing assignment (line 336):
Bug 2 - Deprecated method (line 346):
Expected Behavior
Actual Behavior
Proposed Fix
Fix 1 - Assign the slice result:
Fix 2 - Replace deprecated substr:
Impact
Additional Context
I have a PR ready with both fixes and test cases.