When the from path is "" it will be improperly assigned a null value
Example:
patch: [{"op":"copy","from":"","path":"/archive"}]
JSON: {"wow":"cool"}
The error message:
TypeError: null is not an object (evaluating 'from.get')
(same for move, although that should result in a warning)
Line 448:
var from = operation.from ? new JSONPointer(operation.from) : null;
This seems to be the culprit: operation.from is evaluating as "falsey" when it's an empty string so null is being returned by the ternary expression
One fix is:
var from = operation.from !== undefined ? new JSONPointer(operation.from) : null;
With that in place the operation completes as expected:
{
"wow": "cool",
"archive": {
"wow": "cool"
}
}
Or in the case of a move:
patch: [{"op":"move","from":"","path":"/archive"}]
JSON: {"wow":"cool"}
The proper result now displays:
Error: destination must not be a child of source