From 0591daf93f5331ba5f7562e21a9715224d344b93 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sat, 2 May 2020 11:35:01 +0200 Subject: [PATCH] Fix route regexps aren't global + Version 0.4.21 --- package.json | 2 +- src/Controller.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 16cc8a0..c39ce74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wms-core", - "version": "0.4.20", + "version": "0.4.21", "description": "Node web framework", "repository": "git@gitlab.com:ArisuOngaku/wms-core.git", "author": "Alice Gaudon ", diff --git a/src/Controller.ts b/src/Controller.ts index bbdbd53..135776c 100644 --- a/src/Controller.ts +++ b/src/Controller.ts @@ -12,16 +12,16 @@ export default abstract class Controller { if (path === undefined) throw new Error(`Unknown route for name ${route}.`); if (typeof params === 'string' || typeof params === 'number') { - path = path.replace(/:[a-zA-Z_-]+\??/, '' + params); + path = path.replace(/:[a-zA-Z_-]+\??/g, '' + params); } else if (Array.isArray(params)) { let i = 0; - for (const match of path.matchAll(/:[a-zA-Z_-]+\??/)) { + for (const match of path.matchAll(/:[a-zA-Z_-]+\??/g)) { if (match.length > 0) { path = path.replace(match[0], typeof params[i] !== 'undefined' ? params[i] : ''); } i++; } - path = path.replace(/\/+/, '/'); + path = path.replace(/\/+/g, '/'); } else { for (const key in params) { if (params.hasOwnProperty(key)) {