From a2fe4316373aec39af026055efb928e6f20ebd21 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sun, 2 Sep 2018 09:43:25 +0100 Subject: [PATCH] Add support for arbitrary number of details --- modules/util/keepRight/keepRight_error.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/modules/util/keepRight/keepRight_error.js b/modules/util/keepRight/keepRight_error.js index 137e9692b..6c5341036 100644 --- a/modules/util/keepRight/keepRight_error.js +++ b/modules/util/keepRight/keepRight_error.js @@ -58,9 +58,6 @@ export function parseErrorDescriptions(entity) { var matchingTemplate = errorTypes.errors[errorType] || errorTypes.warnings[errorType]; if (!matchingTemplate) return; - var parsedDetails = []; - var html_re = new RegExp(/<\/[a-z][\s\S]*>/); - var commonEntities = [ 'node', 'way', @@ -85,6 +82,9 @@ export function parseErrorDescriptions(entity) { return; } + var parsedDetails = {}; + var html_re = new RegExp(/<\/[a-z][\s\S]*>/); + // index 0 is the whole match, groups start from 1 for (var i = 1; i < errorMatch.length; i++) { var group = errorMatch[i]; @@ -107,17 +107,10 @@ export function parseErrorDescriptions(entity) { group = t('QA.keepRight.entities.' + group); } - parsedDetails.push(group); + parsedDetails['var' + i] = group; } - return { - var1: parsedDetails[0] || '', - var2: parsedDetails[1] || '', - var3: parsedDetails[2] || '', - var4: parsedDetails[3] || '', - var5: parsedDetails[4] || '', - var6: parsedDetails[5] || '', - }; + return parsedDetails; }