android icon indicating copy to clipboard operation
android copied to clipboard

Fix URLSearchParams.forEach() crash and spec compliance

Open adrian-niculescu opened this issue 1 month ago • 1 comments

Fixes URLSearchParams.forEach() to match the spec.

Equivalent fix for iOS: https://github.com/NativeScript/ios/pull/327

Problem

Calling url.searchParams.forEach() in NativeScript Android crashed with an uncaught NativeScriptException.

Fixes

  1. Crash: Added error handling for callback->Call() return value
  2. Argument order: Changed from (key, value) to (value, key, searchParams)
  3. Duplicate keys: Use get_entries() iterator instead of get_keys() + get()
  4. thisArg: Support the optional second parameter

Changes

  • test-app/runtime/src/main/cpp/URLSearchParamsImpl.cpp
  • test-app/app/src/main/assets/app/tests/testURLSearchParamsImpl.js

Known Limitations (pre-existing)

The entries() and values() methods still use get_keys() + get() which doesn't handle duplicate keys correctly.

adrian-niculescu avatar Dec 09 '25 14:12 adrian-niculescu

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Adrian Niculescu. This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

cla-bot[bot] avatar Dec 09 '25 14:12 cla-bot[bot]