sanity-diff-patch
Advanced tools
Comparing version 3.0.3 to 3.0.4
import { makeDiff, cleanupEfficiency, stringifyPatches, makePatches } from '@sanity/diff-match-patch'; | ||
const IS_DOTTABLE_RE = /^[A-Za-z_][A-Za-z0-9_]*$/; | ||
function pathToString(path) { | ||
@@ -12,5 +13,6 @@ return path.reduce((target, segment, i) => { | ||
return "".concat(target, "[").concat(segment, "]"); | ||
} else if (typeof segment === "string" && (/^\d+$/.test(segment) || segment.includes("-"))) { | ||
return "".concat(target, "[\"").concat(segment, "\"]"); | ||
} | ||
if (typeof segment === "string" && !IS_DOTTABLE_RE.test(segment)) { | ||
return "".concat(target, "['").concat(segment, "']"); | ||
} | ||
if (typeof segment === "string") { | ||
@@ -17,0 +19,0 @@ const separator = i === 0 ? "" : "."; |
{ | ||
"name": "sanity-diff-patch", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"description": "Generates a set of Sanity patches needed to change an item (usually a document) from one shape to another", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
import type {KeyedSanityObject} from './diffPatch.js' | ||
const IS_DOTTABLE_RE = /^[A-Za-z_][A-Za-z0-9_]*$/ | ||
/** | ||
@@ -40,6 +42,8 @@ * A segment of a path | ||
return `${target}[${segment}]` | ||
} else if (typeof segment === 'string' && (/^\d+$/.test(segment) || segment.includes('-'))) { | ||
return `${target}["${segment}"]` | ||
} | ||
if (typeof segment === 'string' && !IS_DOTTABLE_RE.test(segment)) { | ||
return `${target}['${segment}']` | ||
} | ||
if (typeof segment === 'string') { | ||
@@ -46,0 +50,0 @@ const separator = i === 0 ? '' : '.' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
132858
1769