android
android copied to clipboard
Fix URLSearchParams.forEach() crash and spec compliance
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
-
Crash: Added error handling for
callback->Call()return value -
Argument order: Changed from
(key, value)to(value, key, searchParams) -
Duplicate keys: Use
get_entries()iterator instead ofget_keys()+get() - 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.
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:
- check if your git client is configured with an email to sign commits
git config --list | grep email - If not, set it up using
git config --global user.email [email protected] - Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails