From d79b1f94bc3724b05805c8267708dc6e1f002a87 Mon Sep 17 00:00:00 2001 From: hamou Date: Tue, 26 Nov 2024 11:42:36 +0100 Subject: [PATCH] avoid a while loop to prevent infinite loop --- src/app/services/visualize.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/services/visualize.service.ts b/src/app/services/visualize.service.ts index 7cbb8454..83489075 100644 --- a/src/app/services/visualize.service.ts +++ b/src/app/services/visualize.service.ts @@ -76,9 +76,9 @@ export class VisualizeService { /** Fetch all elements between {} in the template. */ const regex = new RegExp(/{([^}]+)}/g); const fields = []; - let match; - while ((match = regex.exec(urlTemplate)) !== null) { - fields.push(match[1]); + const matches = [...urlTemplate.matchAll(regex)]; + if (!!matches) { + matches.filter(m => !!m && Array.isArray(m) && m.length > 1).forEach(m => fields.push(m[1])); } if (fields) { return fields