pywb icon indicating copy to clipboard operation
pywb copied to clipboard

Use native JSON values in query string for POST canonicalization

Open tw4l opened this issue 1 year ago • 0 comments
trafficstars

Fixes #859

Description

Modifies the output of POST canonicalization query strings in pywb to use native JSON values for booleans, numbers, and null, rather than a string representation of their Python values.

This commit also adds a more complicated JSON test case that is also in warcio.js to ensure parity.

We now handle numbers like JavaScript's Number.prototype.toString() by dropping decimal from floats if they represent whole number, to ensure consistency between pywb and warcio.js.

Motivation and context

This is part of a cross-repo effort to standardize how POST canonicalization works in Webrecorder tools, and document this in a Webrecorder specfiication.

Testing notes

Seems to be working well with fuzzy matching on replay, but could use some additional testing.

Types of changes

  • [ ] Replay fix (fixes a replay specific issue)
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [] My change requires a change to the documentation
  • [ ] I have updated the documentation accordingly.
  • [x] I have added or updated tests to cover my changes.
  • [x] All new and existing tests passed.

tw4l avatar Apr 03 '24 19:04 tw4l