fix(core): fix buildUrlParams array handling and replace deprecated substr

MA
3mo ago
+37-3

Description

Fixes #8270

This PR fixes two bugs in the buildUrlParams function:

  1. Missing assignment: Array parameter values had a trailing & that wasn't removed
  2. Deprecated method: Replaced substr(1) with substring(1)

Changes

  • Line 336: Assign the slice result to remove trailing & from array parameters
  • Line 346: Replace deprecated substr() with substring()
  • Line 321: Export buildUrlParams for 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 with substring() or slice()
  • Both fixes are backward compatible and don't change the API