fix(core): fix buildUrlParams array handling and replace deprecated substr
MA
3mo ago+37+37+01234567890123456789-3-3-0123456789
Description
Fixes #8270
This PR fixes two bugs in the buildUrlParams function:
- Missing assignment: Array parameter values had a trailing
&that wasn't removed - Deprecated method: Replaced
substr(1)withsubstring(1)
Changes
- Line 336: Assign the
sliceresult to remove trailing&from array parameters - Line 346: Replace deprecated
substr()withsubstring() - Line 321: Export
buildUrlParamsfor testing - Added test cases to verify the fixes
Testing
- ✅ All existing tests pass (53 tests in core, 41 in CLI)
- ✅ New test cases verify array parameter formatting and initial ampersand removal
Impact
- Type: Bug fix
- Breaking: No
- Platforms: All (affects HTTP plugin URL parameter building)
Before
buildUrlParams({ tags: ['javascript', 'typescript'], key: 'value' })
// Returns: "tags=javascript&tags=typescript&&key=value" ❌
// ^^ double ampersand
After
buildUrlParams({ tags: ['javascript', 'typescript'], key: 'value' })
// Returns: "tags=javascript&tags=typescript&key=value" ✅
Additional Notes
- The
substr()method is deprecated and should be replaced withsubstring()orslice() - Both fixes are backward compatible and don't change the API