Fixed #761: JSON schema errors not rendered in the gutter for mode `code` when the path contained a property with a forward slash
This commit is contained in:
parent
9749a517b1
commit
964fe3e06d
|
@ -5,6 +5,9 @@ https://github.com/josdejong/jsoneditor
|
|||
## not yet published, version 6.4.0
|
||||
|
||||
- Replaces CSS with SASS internally, improvements in styling. Thanks @ppetkow.
|
||||
- Fixed #761: JSON schema errors not rendered in the gutter for mode `code`
|
||||
when the path contained a property with a forward slash, and errors not
|
||||
clickable in the error table.
|
||||
|
||||
|
||||
## 2019-08-15, version 6.3.0
|
||||
|
|
|
@ -1140,7 +1140,7 @@ exports.getPositionForPath = function(text, paths) {
|
|||
|
||||
paths.forEach(function (path) {
|
||||
var pathArr = me.parsePath(path);
|
||||
var pointerName = pathArr.length ? "/" + pathArr.join("/") : "";
|
||||
var pointerName = exports.compileJSONPointer(pathArr);
|
||||
var pointer = jsmap.pointers[pointerName];
|
||||
if (pointer) {
|
||||
result.push({
|
||||
|
@ -1155,6 +1155,21 @@ exports.getPositionForPath = function(text, paths) {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile a JSON Pointer
|
||||
* WARNING: this is an incomplete implementation
|
||||
* @param {Array.<string | number>} path
|
||||
* @return {string}
|
||||
*/
|
||||
exports.compileJSONPointer = function (path) {
|
||||
return path
|
||||
.map(p => ('/' + String(p)
|
||||
.replace(/~/g, '~0')
|
||||
.replace(/\//g, '~1')
|
||||
))
|
||||
.join('');
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the applied color given a color name or code
|
||||
* Source: https://stackoverflow.com/questions/6386090/validating-css-color-names/33184805
|
||||
|
|
|
@ -450,5 +450,12 @@ describe('util', function () {
|
|||
assert.strictEqual(util.limitCharacters('hello world', 100), 'hello world');
|
||||
})
|
||||
|
||||
it('should compile a JSON pointer', function () {
|
||||
assert.strictEqual(util.compileJSONPointer(['foo', 'bar']), '/foo/bar')
|
||||
assert.strictEqual(util.compileJSONPointer(['foo', '/~ ~/']), '/foo/~1~0 ~0~1')
|
||||
assert.strictEqual(util.compileJSONPointer(['']), '/')
|
||||
assert.strictEqual(util.compileJSONPointer([]), '')
|
||||
});
|
||||
|
||||
// TODO: thoroughly test all util methods
|
||||
});
|
Loading…
Reference in New Issue