Fix parsing of error type 294

This commit is contained in:
SilentSpike
2018-09-03 12:24:54 +01:00
committed by Bryan Housel
parent 005927dae3
commit da23bf79a8
2 changed files with 35 additions and 2 deletions
+2 -2
View File
@@ -281,8 +281,8 @@
},
"_294": {
"title": "from or to not a way",
"description": "From- and To-members of turn restrictions need to be ways\\. (.+)",
"TODO": "Group can be any combination of to/from: to node #ID | from node #ID | to relation #ID | from relation #ID",
"description": "From- and To-members of turn restrictions need to be ways\\. ((?:(?:from|to) (?:node|relation) #\\d+,?)+)",
"IDs": ["294"],
"regex": true
},
"_295": {
+33
View File
@@ -111,6 +111,36 @@ export function parseErrorDescriptions(entity) {
return newList.join(', ');
}
// arbitrary node/relation list of form: from node #ID,to relation #ID,to node #ID...
function parseError294(list) {
var newList = [];
var items = list.split(',');
items.forEach(function(item) {
var role;
var idType;
var id;
// item of form "from/to node/relation #ID"
item = item.split(' ');
// to/from role is more clear in quotes
role = '"' + item[0] + '"';
// first letter of node/relation provides the type
idType = item[1].slice(0,1);
// ID has # at the front
id = item[2].slice(1);
id = fillPlaceholder(idType + id);
item = [role, item[1], id].join(' ');
newList.push(item);
});
return newList.join(', ');
}
if (!(entity instanceof krError)) return;
// find the matching template from the error schema
@@ -153,6 +183,9 @@ export function parseErrorDescriptions(entity) {
break;
case '231':
group = parseError231(group);
break;
case '294':
group = parseError294(group);
}
} else if (html_re.test(group)) {
// escape any html in non-IDs