Skip to content
Myr

docs: fix RFC-6902 JSON Pointer path conversion (#1274)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Prefix the joined path with "/" so normalized patch paths match RFC-6901 JSON Pointers. Also note token escaping for "~" and "/". Fixes #1051

authored by Hashim Khan · committed by GitHub · parent 36f340c · Browse files · 2 files+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+2 added−2 removed

  • other:+2 added−2 removed

2 files+2 added−2 removed

modified:website/docs/patches.mdx+1 added-1 removed
116 unmodified lines
117 age: 32 // Reverted118})119```120121The generated patches are similar (but not the same) to the [RFC-6902 JSON patch standard](https://datatracker.ietf.org/doc/html/rfc6902/#section-4.1), except that the `path` property is an array, rather than a string. This makes processing patches easier. If you want to normalize to the official specification, `patch.path = patch.path.join("/")` should do the trick. Anyway, this is what a bunch of patches and their inverse could look like:121The generated patches are similar (but not the same) to the [RFC-6902 JSON patch standard](https://datatracker.ietf.org/doc/html/rfc6902/#section-4.1), except that the `path` property is an array, rather than a string. This makes processing patches easier. If you want to normalize to the official specification, use `patch.path = "/" + patch.path.join("/")` so the result is a JSON Pointer with a leading `/` (and escape `~` / `/` in path tokens per [RFC-6901](https://datatracker.ietf.org/doc/html/rfc6901) when needed). Anyway, this is what a bunch of patches and their inverse could look like:122123```json124[125 {
102 unmodified lines
modified:website/i18n/zh-CN/docusaurus-plugin-content-docs/current/patches.mdx+1 added-1 removed
117 unmodified lines
118 age: 32 // 还原了119})120```121122生成的 patches 与 [RFC-6902 JSON patch standard](https://datatracker.ietf.org/doc/html/rfc6902/#section-4.1) 类似(但并不相同),除了 path 属性是一个数组,而不是一个字符串。这使得处理 patches 更加容易。如果你想规范化到官方格式,`patch.path = patch.path.join("/")`应该可以解决这个问题。无论如何,下面就是一堆 patches 和它们回溯的样子。122生成的 patches 与 [RFC-6902 JSON patch standard](https://datatracker.ietf.org/doc/html/rfc6902/#section-4.1) 类似(但并不相同),除了 path 属性是一个数组,而不是一个字符串。这使得处理 patches 更加容易。如果你想规范化到官方格式,请使用 `patch.path = "/" + patch.path.join("/")`,这样会得到带前导 `/` 的 JSON Pointer(如有需要,请按 [RFC-6901](https://datatracker.ietf.org/doc/html/rfc6901) 转义路径段中的 `~` / `/`)。无论如何,下面就是一堆 patches 和它们回溯的样子。123124```json125[126 {
102 unmodified lines