Repository navigation
Conversation
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D127563127. |
Collaborator
|
This pull request was successfully merged by @Marve10s in 778fef7 When will my fix make it into a release? | How to file a pick request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
URLSearchParams.sort()currently useslocaleCompare, so query names follow locale collation instead of the UTF-16 code-unit order required by the URL standard. Sorting the same parameters in React Native and a browser can therefore produce different query strings.For example:
On React Native 0.88.0 and main, this produces
a=first&a=second&%C3%A4=umlaut&z=last&Z=upperin an English locale. The expected result isZ=upper&a=first&a=second&z=last&%C3%A4=umlaut.Compare names directly as strings to use code-unit order, preserve duplicate values, and remove the collation dependency. This also lets the existing Fantom URL test exercise sorting again, which was omitted because its Hermes build lacks ICU collation support.
Changelog:
[GENERAL] [FIXED] - Sort URLSearchParams names in UTF-16 code-unit order instead of locale order.
Test Plan:
Ran the existing URL test file headlessly using the root Jest configuration with a temporary adapter. The adapter selects
URL-itest.jsand aliases only@react-native/fantom/src/setUpDefaultReactNativeEnvironmentto an empty module, retaining Jest's environment setup and the real URL classes.All three tests pass. Against the original implementation, the existing URL test passes and both new sorting regressions fail. They cover mixed-case and accented names, duplicate values, and supplementary characters whose UTF-16 ordering differs from code-point ordering.
ESLint, formatting, and focused Flow checking pass. Independent Node probes reproduce the failures on 0.88.0 and main. Substituting the comparator matches native URLSearchParams ordering and still works when
localeCompareis forced to throw.These are headless Node checks. The native Fantom runner, native builds, and full-repository checks were not run.