Skip to content

Function ensurePathExists should handle appending correctly - #148

Merged
evanphx merged 1 commit into
evanphx:masterfrom
MarcelMue:fix-ensurePathExists
Oct 20, 2021
Merged

evanphx merged 1 commit into
evanphx:masterfrom
MarcelMue:fix-ensurePathExists

Conversation

@MarcelMue

Copy link
Copy Markdown
Contributor

Previously this failed unexpectedly by not creating an array.

Comment thread v5/patch_test.go
},
{
`{ "foo": [{"bar": [{"baz0": "123"}]}]}`,
`[ { "op": "add", "path": "/foo/1/bar/-", "value": {"baz1": "456"} } ]`,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other added testcases worked previously - this one failed.

Comment thread v5/patch.go
// Check if the next part is a numeric index or "-".
// If yes, then create an array, otherwise, create an object.
if arrIndex, err = strconv.Atoi(parts[pi+1]); err == nil {
if arrIndex, err = strconv.Atoi(parts[pi+1]); err == nil || parts[pi+1] == "-" {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should check for - here as it's intuitive behavior to me at least.

@MarcelMue

Copy link
Copy Markdown
Contributor Author

@evanphx Let me know if I need to do anything to help with merging this :)

@MarcelMue

Copy link
Copy Markdown
Contributor Author

Friendly ping @evanphx

@zhangguanzhang

Copy link
Copy Markdown

@evanphx PTAL

@boindil

boindil commented Oct 20, 2021

Copy link
Copy Markdown

@evanphx you still with us?

@evanphx
evanphx merged commit 556cb64 into evanphx:master Oct 20, 2021
@evanphx

evanphx commented Oct 20, 2021

Copy link
Copy Markdown
Owner

Sorry for the delay!

@MarcelMue
MarcelMue deleted the fix-ensurePathExists branch October 21, 2021 09:21
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.

4 participants