Skip to content

Conversation

@adrian-niculescu
Copy link

@adrian-niculescu adrian-niculescu commented Dec 9, 2025

Fixes URLSearchParams.forEach() to match the spec.

Equivalent fix for iOS: NativeScript/ios#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.

@cla-bot
Copy link

cla-bot bot commented Dec 9, 2025

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

- Added error handling for callback->Call() return value
- Changed argument order from (key, value) to (value, key, searchParams)
- Use get_entries() iterator to correctly handle duplicate keys
- Added support for optional thisArg parameter
- Added unit tests for forEach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant