fix(json-sorter): __proto__ key disappears from the output #34
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
needs-info
needs-triage
question
ready-for-agent
ready-for-human
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
flopana/OpenDevTools#34
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #30
Branch:
feature/improve-json-sorterBug
sortObjKeysinJsonSorter.tsxassignssortedObj[key] = .... For the key__proto__this sets the prototype, soJSON.stringifydrops the key.{"b":1,"__proto__":{"x":1}}{"b":1}Verification: the review agent checked the fix in node. The bug follows from how JS assigns
__proto__.Red test
Add
src/lib/jsonSorter.test.ts. The input above keeps the__proto__key. Also cover nested objects, arrays and primitive roots.Fix
sortObjKeysandJsonValuetosrc/lib/jsonSorter.ts.Object.fromEntries.JSON.stringify(obj, null, 2)validity check.Known limit, no fix
JS objects put integer-like keys first.
{"b":1,"10":2,"2":3}gives{"2":3,"10":2,"b":1}.