gson-pointer
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -12,4 +12,3 @@ "use strict"; | ||
var lastProperty = properties.pop(); | ||
var toParent = properties; | ||
var target = get(data, toParent); | ||
var target = get(data, properties); | ||
if (target) { | ||
@@ -16,0 +15,0 @@ delete target[lastProperty]; |
@@ -8,2 +8,4 @@ "use strict"; | ||
var matchMutlipleSlashes = /\/+/g; | ||
var matchTildes = /~/g; | ||
var matchSlashes = /\//g; | ||
@@ -18,3 +20,3 @@ | ||
for (var i = 0, l = list.length; i < l; i += 1) { | ||
list[i] = list[i].replace("~", "~0").replace("/", "~1"); | ||
list[i] = list[i].replace(matchTildes, "~0").replace(matchSlashes, "~1"); | ||
if (isURI) { | ||
@@ -21,0 +23,0 @@ list[i] = encodeURIComponent(list[i]); |
@@ -25,4 +25,4 @@ "use strict"; | ||
const sanitize = pointer.indexOf("#") >= 0 ? sanitizeAndDecodeProperty : sanitizeProperty; | ||
pointer = pointer.replace(matchMutlipleSlashes, "/"); // remove multiple slashes | ||
pointer = pointer.replace(matchPointerPrefixes, ""); // strip pointer prefixes | ||
pointer = pointer.replace(matchMutlipleSlashes, "/"); | ||
pointer = pointer.replace(matchPointerPrefixes, ""); | ||
@@ -29,0 +29,0 @@ var result = pointer.split("/"); |
{ | ||
"name": "gson-pointer", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "json pointer - failsafe data retrieval on js and json objects", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -24,4 +24,2 @@ # gson-pointer - a json-pointer implementation | ||
Besides the standard `get` function, this library offers additional functions to work with json-pointer | ||
| method | description | ||
@@ -33,3 +31,2 @@ | ------------------------------------- | ------------------------------------------------------------- | ||
| join(...pointers) -> pointer | joins multiple pointers to a single one | ||
| join([properties], isURI) -> pointer | joins all properties in the given mode | ||
| split(pointer) -> [array] | returns a json-pointer as an array | ||
@@ -64,3 +61,3 @@ | ||
and may optionally pass a default value with | ||
and may optionally return a default value with | ||
@@ -103,3 +100,3 @@ ```js | ||
and may used to create data structures | ||
and may be used to build data | ||
@@ -201,3 +198,3 @@ ```js | ||
// passing the array directly, will treat each entry as a property, which will be escaped and resolves to: | ||
gp.join(['/path/to/value', '../object']); // output: '/~1path/to/value/..~1object' | ||
gp.join(['/path/to/value', '../object']); // output: '/~1path~1to~1value/..~1object' | ||
``` | ||
@@ -204,0 +201,0 @@ |
175
31737
218