Skip to content

fix: fixed issues handling empty keys + separator characters in the key#234

Open
raing3 wants to merge 4 commits intodevelohpanda:masterfrom
raing3:fix/edge_case_key_issues
Open

fix: fixed issues handling empty keys + separator characters in the key#234
raing3 wants to merge 4 commits intodevelohpanda:masterfrom
raing3:fix/edge_case_key_issues

Conversation

@raing3
Copy link

@raing3 raing3 commented Mar 6, 2023

PR is to fix a couple of issues I encountered while trying to use this library:

  1. If you have an empty key in your JS object it disappears from the object when sorting it.
  2. If your key contains the separator string it disappears from the object when sorting it.
  3. If a "null" value is encountered in the encoded JSON an error was previously thrown (null is an object so passes through the existing if logic but then Object.keys throws).

Notes:

  • Hopefully the tests show the issues well enough.
  • Haven't had to handle interpreting escape sequences before so there may be a better way to do this, or may be something I have overlooked but tried to make the tests cover as many different odd scenarios I could think of.
  • Could be argued to be a BC breaking change as the "" character is no longer supported.

Let me know if any changes are needed to get this merged and released. Thanks!

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