From d8432301589baad28de30c194ec2c5a1937acea5 Mon Sep 17 00:00:00 2001 From: Samuel Date: Wed, 7 Oct 2020 13:53:20 +0200 Subject: [PATCH] Add statistics pages - fix link caching issue --- src/app/shared/menu/menu.effects.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/app/shared/menu/menu.effects.ts b/src/app/shared/menu/menu.effects.ts index d8aa64f862..a9aa07daad 100644 --- a/src/app/shared/menu/menu.effects.ts +++ b/src/app/shared/menu/menu.effects.ts @@ -88,28 +88,32 @@ export class MenuEffects { private resolveSubstitutions(object, params) { + let resolved; if (typeof object === 'string') { + resolved = object; let match: RegExpMatchArray; do { - match = object.match(/:(\w+)/); + match = resolved.match(/:(\w+)/); if (match) { const substitute = params[match[1]]; if (hasValue(substitute)) { - object = object.replace(match[0], `${substitute}`); + resolved = resolved.replace(match[0], `${substitute}`); } } } while (match); } else if (Array.isArray(object)) { + resolved = []; object.forEach((entry, index) => { - object[index] = this.resolveSubstitutions(object[index], params); + resolved[index] = this.resolveSubstitutions(object[index], params); + }); + } else if (typeof object === 'object') { + resolved = {}; + Object.keys(object).forEach((key) => { + resolved[key] = this.resolveSubstitutions(object[key], params); }); } else { - Object.keys(object).forEach((key) => { - object = Object.assign({}, object, { - [key]: this.resolveSubstitutions(object[key], params) - }); - }); + resolved = object; } - return object; + return resolved; } }