-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
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 deprecatedExpected 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.