Skip to content

Commit f552df7

Browse files
authored
v0.9.12 - no comments (fixed)
Restored lines, errantly taken out during comment removal. The main jsonpath was not affected.
1 parent 254b8e9 commit f552df7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

jsonpath.no_comment.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// JSONPath 0.9.12 - XPath for JSON
1+
// JSONPath 0.9.12 (no comments) - XPath for JSON
22
// Copyright (c) 2020 Joel Bruner (https://github.com/brunerd)
33
// Copyright (c) 2020 "jpaquit" (https://github.com/jpaquit)
44
// Copyright (c) 2007 Stefan Goessner (goessner.net)
@@ -8,6 +8,7 @@
88
//The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
99
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1010

11+
1112
function jsonPath(obj, expr, arg) {
1213
var P = {
1314
resultType: arg && arg.resultType || "VALUE",
@@ -225,6 +226,7 @@ function jsonPath(obj, expr, arg) {
225226
for (var i=0,n=x.length; i<n; i++){
226227

227228
if(P.resultType === "PATH_JSONPOINTER") {
229+
p += "/" + (x[i].constructor === Number ? x[i] : x[i].replace(/~/g,"~0").replace(/\//g,"~1"))
228230
}
229231
else {
230232
var pathString = x[i].constructor === Number ? "["+x[i]+"]" : (P.resultType === "PATH_DOTTED" && /^[A-Za-z_$][\w\d$]*$/.test(x[i]) ? "." + x[i] : ("["+ qt + (P.singleQuoteKeys ? x[i].replace(/'/g,"\\'") : x[i].replace(/"/g,'\\"')) + qt + "]").replace(/\n/g,'\\n').replace(/[\b]/g,'\\b').replace(/\f/g,'\\f').replace(/\r/g,'\\r').replace(/\t/g,'\\t').replace(/[\u0000-\u001f\u007f]/g, function(chr) {return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).slice(-4)}));
@@ -422,8 +424,7 @@ function jsonPath(obj, expr, arg) {
422424
}
423425
catch(e) {
424426
throw new SyntaxError("eval: " + e.message + ": " + x.replace(/(^|[^\\])@/g, "$1_v")
425-
.replace(/\\@/g, "@") /* issue 7 : resolved .. */
426-
/* 2020/01/09 - manage regexp syntax "=~" */
427+
.replace(/\\@/g, "@")
427428
.replace(/(_v(?:(?!(\|\||&&)).)*)=~((?:(?!\)* *(\|\||&&)).)*)/g,
428429
function(match, p1, p2, p3, offset, currentString) {
429430
return match ? p3.trim()+'.test('+p1.trim()+')' : match

0 commit comments

Comments
 (0)