fix validation of array indices
This commit is contained in:
@@ -122,6 +122,9 @@ class JsonPointer(object):
|
|||||||
def to_last(self, doc, default=_nothing):
|
def to_last(self, doc, default=_nothing):
|
||||||
""" Resolves ptr until the last step, returns (sub-doc, last-step) """
|
""" Resolves ptr until the last step, returns (sub-doc, last-step) """
|
||||||
|
|
||||||
|
if not self.parts:
|
||||||
|
return doc, None
|
||||||
|
|
||||||
for part in self.parts[:-1]:
|
for part in self.parts[:-1]:
|
||||||
doc = self.walk(doc, part)
|
doc = self.walk(doc, part)
|
||||||
|
|
||||||
@@ -158,7 +161,7 @@ class JsonPointer(object):
|
|||||||
if part == '-':
|
if part == '-':
|
||||||
return part
|
return part
|
||||||
|
|
||||||
if not RE_ARRAY_INDEX.match(part):
|
if not RE_ARRAY_INDEX.match(str(part)):
|
||||||
raise JsonPointerException("'%s' is not a valid list index" % (part, ))
|
raise JsonPointerException("'%s' is not a valid list index" % (part, ))
|
||||||
|
|
||||||
return int(part)
|
return int(part)
|
||||||
|
|||||||
Reference in New Issue
Block a user